Retrieve your API access_token (option two)

Before you can make API calls, you will need to retrieve your API access_token. There are two methods to retrieve your access_token.

1. Token API in Postman
  1. Fork the Authentication API on Postman.
  2. Add your clientID and clientSecret as variables.
  3. Set up the Authentication to use Basic Auth with your clientID and clientSecret as the Username and Password (respectively).
  4. Set the POST Token API to “Inherit auth from parent”.
  5. Call the Post Token API. The response will have your access_token.
  6. (Optional) Under the Scripts tab, you could add the script below to the Post-response section to automatically update your access_token and add it as an Environment Variable every time you call the Post Token API. By default, the variable is named, “token”. You could change the name to something of your choice.

    tests["STATUS"] = responseCode.code === 200
    var response = JSON.parse(responseBody);
    pm.environment.set("token", response.access_token);
    
2. Command Line

The access_token is generated by the Token API with a Base64 (utf-8, Unix newline separators) encoding of your client ID and client secret.

  1. Call the Token API with a Base64 (utf-8, Unix newline separators) encoding of your client ID and client secret to generate the access_token. The encoded string is used for the Authorization header parameter.


    🚧

    Note: You can use many different online and offline tools to create the encoded key. However, we highly recommend you use an offline script. The client ID and client secrets are highly confidential information. You can use the Python script below to safely encode your key offline. Swap out the placeholders, “” and “” with your actual values.

    import base64; encoded_string= base64.b64encode("<client-ID>:<client-secret>".encode('utf-8')); print(encoded_string)
    
  2. Use the Python command below to call the Token API and retrieve your access_token. Swap out <randomly-generated-GUID> with a randomly generated GUID.

    python -m pip install requests
    import requests
    url = "https://marketplace.walmartapis.com/v3/token"
    payload = { "grant_type": "client_credentials" } headers = { "accept": "application/json", "Authorization": "Basic <encoded_string>", "Content-Type": "application/x-www-form-urlencoded", "WM_QOS.CORRELATION_ID": "<randomly-generated-GUID>", "WM_SVC.NAME": "Walmart Marketplace" } access_token= requests.post(url, data=payload, headers=headers)
    print(access_token.text)
    

With your access_token , you can use it to make API calls with the other APIs offered by the Walmart Marketplace team. You will use the access_token for the WM_SEC.ACCESS_TOKEN header parameter (send the parameter with this format: Basic access_token ) for all other API calls.

You could also use the APIs Try it Out environment to learn how to use the Token API and other APIs too.

A few of the frequently used APIs are listed below:

You can review the other APIs in the Marketplace Developer Portal.