Skip to main content

A python client to access the FIRST Tech Challenge API

Project description

FTC api

A python client library for accessing FTC Events API

API docs here

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

  1. Every path/method combo becomes a Python module with four functions:

    1. sync: Blocking request that returns parsed data (if successful) or None
    2. sync_detailed: Blocking request that always returns a Request, optionally with parsed set if the request was successful.
    3. asyncio: Like sync but async instead of blocking
    4. asyncio_detailed: Like sync_detailed but async instead of blocking
  2. All path/query params, and bodies become method arguments.

  3. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)

  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ftc_api-0.1.0.tar.gz (33.2 kB view hashes)

Uploaded Source

Built Distribution

ftc_api-0.1.0-py3-none-any.whl (61.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page