iwf
    Preparing search index...

    Function upload

    • Uploads an Item to a Wikibase instance (e.g., Wikidata)

      Parameters

      • item: Item

        The item you want to upload to Wikidata

      • options: UploadOptions

        The options for uploading

        • summary

          The summary for the edit (displayed in the history of Wikidata)

        • tags

          The tags for the edit (displayed in the history of Wikidata)

        • auth

          The BotPasswordAuth instance to use for authentication

        • anonymous

          If true, the upload will be anonymous

        • maxLag

          The max lag in seconds for the API request (see https://www.mediawiki.org/wiki/Manual:Maxlag_parameter)

        • server

          The API endpoint to use (defaults to Wikidata)

        • origin

          The origin to use for the API calls, aka the "domain" of the web app (only needed for CORS)

        • axiosOptions

          The options to pass to axios

        • userAgent

          The user agent to use for the request (required for anonymous uploads)

      Returns Promise<Item>

      A Promise for the item after uploading

      If no authentication method is provided or the upload fails

      // Using BotPasswordAuth (recommended)
      const auth = new BotPasswordAuth({
      username: 'MainAccount@BotName',
      password: 'botpassword123',
      userAgent: 'MyBot/1.0'
      });
      await upload(item, {
      summary: 'test update',
      auth
      });
      // Anonymous upload
      await upload(item, {
      summary: 'anonymous edit',
      anonymous: true,
      origin: 'https://my-app.example.com',
      userAgent: 'MyApp/1.0'
      });