Skip to content

Easily make API calls to commercetools Composable Commerce.

Notifications You must be signed in to change notification settings

industrian/commercetools-rest-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

commercetools-rest-client

This repository contains .http files which you can use to interact with commercetools Composable Commerce APIs using the REST Client extension for Visual Studio Code.

Disclaimer

  • This repository and its contents are not provided by or supported by commercetools.
  • The .http files and their API calls are intended for testing/evaluation purposes only and should not be used in production.
  • The .http files and their contents are accurate as of the time their files were last updated.

You should consult the commercetools documentation for more information regarding required fields and data types in each API call.

Requirements

Set up

  1. Open the Command Palette and select Preferences: Open User Settings (JSON).

    Screenshot_30

  2. If this file does not have an entry called rest-client.environmentVariables, then create one. When you start typing, you should be prompted to create it using autocomplete.

    Screenshot 2024-05-14 at 09 08 31

  3. In rest-client.environmentVariables, add an object with your Project key as the name. This will set up an environment for the Project. The following fields and values must be added:

    • project-key: the Project key
    • client_secret: your API Client secret
    • client_id: your API Client id
    • auth_url: the authorization URL of the region your Project is hosted with no trailing /. For example: auth.europe-west1.gcp.commercetools.com
    • host: the URL of the region your Project is hosted. Do not include api or a trailing /. For example: europe-west1.gcp.commercetools.com
    • scopes: your API Client scopes

    For example:

    image

You can define multiple Projects within the settings file. These Projects can then be switched by clicking the Switch REST Client Environment button.

Screenshot_36

Making API calls

Each API call is within a dedicated .http file, nested under folders representing the resource. Update actions are also within a dedicated folder.

At the beginning of every file is an Authentication call. You must make this call first as it will get and save the bearer token to use in the actual API call.

Variables used within API calls are defined above the call. You should define these before sending the API request. For example, in the following you must add a category-id and category-version. Strings should not be enclosed in quotation marks.

Screenshot_37

In some API calls you can define query parameters (such as where or sort). Placeholders for these parameters are included, but commented out. To define a query parameter, remove the # and include a value. Please note that you should change the & to ? if it is the first (or only) query parameter. Please note that in some calls some query parameters are required. For more information, consult the commercetools documentation.

About

Easily make API calls to commercetools Composable Commerce.

Topics

Resources

Stars

Watchers

Forks