Get started¶
Requirements¶
- Python 3.11 or later.
- A DRS API key.
Get an API key¶
- Go to drs.faa.gov.
- Open DRS Help & Training, then DRS API.
- Click Request / Renew API Key.
- Follow the steps.
Install¶
Set the API key¶
Set the DRS_API_KEY environment variable:
The client reads this variable. You can also give the key directly:
Warning
Do not put the API key in source code that you share.
Make a request¶
from faa_drs import DRSClient, DocType
with DRSClient() as drs:
page = drs.list_documents(DocType.AC)
print(page.total)
for doc in page.documents[:5]:
print(doc.number, doc.status, doc.title)
list_documents gets one page. iter_documents gets all pages:
Always close the client. Use a with block, or call drs.close().
Read a document¶
A Document has common fields as attributes:
| Attribute | Description |
|---|---|
guid |
Unique ID in DRS. Always present. |
doctype |
Document type code. |
number, title, status |
Values of drs:documentNumber, drs:title and drs:status. |
last_modified |
Last change in DRS (UTC). Can be None. |
url |
Page in the DRS web application. |
download_url, file_name |
Main file. None if there is no file. |
has_attachments |
True if there are more files. |
content |
Full text fields, if the API supplies them. |
Other fields are in doc.metadata. Use the API field name:
doc["drs:approvalDate"] # Raises KeyError if missing.
doc.get("drs:cancels") # Returns None if missing.
doc.get_list("drs:partNumber") # Always a list of strings.
doc.get_date("drs:approvalDate") # A datetime.date, or None.
To find the fields of a document type, see Filters.