Once you are happy that the code snippet you have configured is working you can copy this use this in your own environment.
In the previous article we ended up with the following code
This can be copied using the button to the right of the REQUEST header and would look something like this...
curl https://demo.graft.com/v1/query -H 'Content-Type: application/json' -X POST -d '{
"secret": "fgXHkjDE ... ENTER YOUR FULL API KEY HERE",
"organization": "docs",
"project": "g3bvz",
"output_format": "csv",
"entity": "my_first_search_app",
"entity_columns": [
"product_id",
"product_category",
"product_subcategory",
"product_title",
"product_description",
"price",
"season",
"image_uri"
],
"entity_knn_adhoc": [
{
"image_uri": "https://graft.zendesk.com/hc/article_attachments/17962302051725"
}
],
"entity_knn_k": 10,
"rerank": false
}'
Where only a small part of the API key is presented.
Organization, project & entity would be unique to your application in Graft.
This code can be adjusted for your particular environment and application with your application providing the image URI for any image that you or your customers have provided.
Enabling the API
To be able to use your code externally you need to enable this Application to use the API. In the screenshot above you can see in the top right hand corner API DISABLED
Click on the API DISABLED link to jump directly to the App SETTINGS tab (or click on the SETTINGS tab)
- To toggle the API on click on the Enable API toggle (it will turn green)
- Click SAVE to confirm the change
API limits
Note your Graft plan may limit the number of active Apps, you may need to deactivate an App's API to enable anothers or consider upgrading to a bigger tier
Example external use of your code snippet
For example using a simple tool like postman you are able to use the code above to request results from Graft. (API Key hidden)
Note if you receive the following error from postman, your API is not enabled, please follow the procedure above to Enable
{
"detail": "search app instance corresponding to entity my_first_search_app in project g3bvz is not active."
}
Postman Results
Clicking SEND in Postman generates results