Index your feed directly using the Index API
The Index API is the main entry point for any interaction required with the feed indexing process.
interact
The Index section of the Playboard's Instance Management Console is the user-friendly foreground for directly interacting with the feed indexing process.
Consuming the Index API
There are several ways to consume an API. Here are the three most common ways.
interact
Remember that you can get the Index API .yaml file from the API Reference.
OpenAPI
You have published the Index API in Swagger (opens new window)(external link), so you are allowed to interact with the API easily and see the responses in a more human-readable way.
cURL
This is the most basic way of interacting with the API. You only need a terminal. With just the following command, you can submit a job to index a catalog type feed:
curl --request POST \
--url https://{HOST}/jobs/submit/empathy/{CLIENT_TOKEN}/catalog \
--header 'Content-Type: application/gzip' \
--data '@{FEED_FILE_PATH}'
Where:
HOST
is the host of the environment you are working on.CLIENT_TOKEN
is the token of the client you want to index the feed for. This is a unique identifier for each client and can be obtained from the Index API as well. Follow the instructions of the Getting the client token section.FEED_FILE_PATH
is the path in your local machine where the feed file you want to index is located.
Here, there is only one example of how to submit a feed file.
Getting the client token
The request to obtain the client token (CLIENT_TOKEN
) is the following:
curl --request GET \
--url https://{HOST}/clients/empathy \
--header 'Authorization: Bearer {ACCESS_TOKEN}'
warning
The value for ACCESS_TOKEN
is obtained from the authentication endpoint. To learn how to get it, check the Getting the access token section.
The value you want to take from the response is the token
field. You will need this value for almost every request made to the Index Pipeline API.
Getting the access token
The access token (CLIENT_TOKEN
) is widely used across Empathy's services and is used to authenticate the user making the request. In order to do so, you need to make a request to the OAuth2 token endpoint as follows:
curl --request POST \
--url https://{HOST}/oauth/token \
--header 'Authorization: Basic {BASIC_TOKEN}' \
--header 'Content-Type: multipart/form-data' \
--form grant_type=password \
--form username={USERNAME} \
--form password={PASSWORD}
Where:
HOST
is the host of the OAuth2 service for the environment you are working on.BASIC_TOKEN
is the base64 encoded string of the client ID and client secret.USERNAME
is the username of the user you want to authenticate (for example, your Empathy email).PASSWORD
is the password of the user you want to authenticate (for example, your Empathy password).
Once you make the request, take the access_token
value from the response and use it when needed.
API clients
API clients are a more user-friendly way of interacting with the Index API. The two more common clients used at Empathy.co are Insomnia and Postman. Below, you find how to import the API specifications in both of them to start using the API. You can get the Index API .yaml file from the API Reference. Then, follow the steps in each case to import the collection for your client.
Insomnia: Import the API specifications by following their official documentation (opens new window)(external link). Notice that you want to import a .yaml file, not a URL.
Postman: Import the API specifications by following their official documentation (opens new window)(external link). Here, you can directly paste the content of the .yaml file without saving it or just importing it from your local.