A python client to access the FIRST Tech Challenge API
Project description
FTC api
A python client library for accessing FTC Events API
Most of the code here is auto generated by openapi-python-client, but some of it has been modified for the convenience of the user.
Usage
First, create a client:
from ftc_api import Client
client = Client(token="Insert Token Here")
Alternatively, use your username and access key, and the token will be automatically generated:
from ftc_api import Client
client = Client(username="test", authorization_key="****-****-****-****")
Now call your endpoint and use your models:
from ftc_api.api.season_data import get_v2_0_season
import ftc_api
client = ftc_api.Client(username="test", authorization_key="****-****-****-****")
my_data = get_v2_0_season.sync(client=client, season=2022)
print(my_data.game_name) # POWERPLAY
# or if you need more info (e.g. status_code)
response = get_v2_0_season.sync_detailed(client=client, season=2022)
print(response.headers) # server headers
print(response.content) # raw json
Or do the same thing with an async version:
from ftc_api.api.season_data import get_v2_0_season
import ftc_api
client = ftc_api.Client(username="test", authorization_key="****-****-****-****")
my_data = await get_v2_0_season.asyncio(client=client, season=2022)
print(my_data.game_name) # POWERPLAY
# or if you need more info (e.g. status_code)
response = await get_v2_0_season.asyncio(client=client, season=2022)
print(response.headers) # server headers
print(response.content) # raw json
Things to know
-
Every path/method combo becomes a Python module with four functions:
sync
: Blocking request that returns parsed data (if successful) orNone
sync_detailed
: Blocking request that always returns aRequest
, optionally withparsed
set if the request was successful.asyncio
: Likesync
but async instead of blockingasyncio_detailed
: Likesync_detailed
but async instead of blocking
-
All path/query params, and bodies become method arguments.
-
If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
-
Any endpoint which did not have a tag will be in
ftc_events_api_client.api.default
Updates
FIRST releases major updates with new season-specific models every year, the project will be updated with these new models.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.