API's

Last updated: 01/04/2021

All of our publishers get access to API endpoints to manage their Github repositories and branches.
Through these API's it should be possible to automate your processes so you don't need to login to our platform and manually click on update every time.

1. Updating a Github repository

If you've made an update to multiple branches and want to trigger our platform to update the whole repository (so all branches) you can do it by calling our endpoint:

/api/repository/<github_username>/<repository_name>/update

This API endpoint requires a POST and requires user authentication. This means that you will need to post along session details just like with default Odoo POST commands.
The endpoint is limited to 5 calls per 15 minutes to avoid abuse and overusage.

2. Updating a Github branch

If you've made an update to one branche and want to trigger our platform to update this specific branch you can do it by calling our endpoint:

/api/branch/<github_username>/<repository_name>/<branch_name>/update

This API endpoint requires a POST and requires user authentication. This means that you will need to post along session details just like with default Odoo POST commands.
The endpoint is limited to 5 calls per 15 minutes to avoid abuse and overusage.

3. Sample Python script

Not sure how to start or how to do this?
You can use this code sample. Just adjust the 'db_username', 'db_password', 'github_username' and 'github_repository' in the following script:

import json
import urllib.request
import requests
database = 'theodoostore'
odoo_url = 'www.theodoostore.com'
db_username = 'your_store_username'
db_password = 'your_store_password'
github_username = 'your_github_username'
github_repository = 'github_repository_name'


data_string = {
    'jsonrpc': '2.0',
    'params': {
    'context': {},
    'db': database,
    'login': db_username,
    'password': db_password}
}


# Get the session details from /web/session/authenticate
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}


session_details = requests.get(
    url=odoo_url + '/web/session/authenticate',
    data=json.dumps(data_string),
    headers=headers
)


session_id = str(session_details.cookies.get('session_id'))

cookies = {
    'username': db_username,
    'password': db_password,
    'session_id': session_id
}


result = requests.post(
    url=odoo_url + '/api/repository/' + github_username + '/' + github_repository + '/update',
    data=json.dumps({}),
    headers=headers,
    cookies=cookies
)
print('Response code: ' + str(result.status_code))
print('Response: ' + str(result.text))