Implementation example of Tokopedia OpenAPI using Python, with some of its Product API functions:
- get product info
- get all etalase
- update stock
- update price
- Fill out the constants in the Python code
client_id = b'<your client_id>' client_secret = b'<your client_secret>' fs_id = '<your fs_id>' shop_id = '<your shop_id>'
- Install dependencies
pip install requests
- This script will generate file "tokopedia_token.txt" in the same directory it's executed. This file will be used to save token. Make sure add proper permissions to write, read, and execute.
$ ./tokopedia.py
python tokopedia.py
$ ./tokopedia.py
tokopedia_token.txt not found, creating one.
get_token(): response {"access_token":"<>","event_code":"","expires_in":<>,"last_login_type":"<>","sq_check":<>,"token_type":"Bearer"}
{
"data": {
"etalase": [
{
"alias": "<>",
"etalase_id": <>,
"etalase_name": "<>",
"url": "<>"
},
{
"alias": "<>",
"etalase_id": <>,
"etalase_name": "<>",
"url": "<>"
},
{
"alias": "<>",
"etalase_id": <>,
"etalase_name": "<>",
"url": "<>"
}
],
"shop": {
"id": <>,
"location": "<>",
"name": "<>",
"uri": "<>"
}
},
"header": {
"messages": "Your request has been processed successfully",
"process_time": 0.080218411
}
}