stableapi-airflow 1.0.0
Airflow API (Stable)
Keywords: Swagger,Airflow API (Stable)

# Overview  To facilitate management, the Apache Airflow supports a range of REST API endpoints across its objects. This section provides an overview of the API design, methods, and supported use cases.  Most of the endpoints accept &#x60;JSON&#x60; as input and return &#x60;JSON&#x60; responses. This means that you must usually add the following headers to your request: &#x60;&#x60;&#x60; Content-type: application/json Accept: application/json &#x60;&#x60;&#x60;  ## Resources  The term &#x60;resource&#x60; refers to a single type of object in the Airflow metadata. An API is broken up by its endpoint&#x27;s corresponding resource. The name of a resource is typically plural and expressed in camelCase. Example: &#x60;dagRuns&#x60;.  Resource names are used as part of endpoint URLs, as well as in API parameters and responses.  ## CRUD Operations  The platform supports **C**reate, **R**ead, **U**pdate, and **D**elete operations on most resources. You can review the standards for these operations and their standard parameters below.  Some endpoints have special behavior as exceptions.  ### Create  To create a resource, you typically submit an HTTP &#x60;POST&#x60; request with the resource&#x27;s required metadata in the request body. The response returns a &#x60;201 Created&#x60; response code upon success with the resource&#x27;s metadata, including its internal &#x60;id&#x60;, in the response body.  ### Read  An HTTP &#x60;GET&#x60; request can be used to read a resource or to list a number of resources.  A resource&#x27;s &#x60;id&#x60; can be submitted in the request parameters to read a specific resource. The response usually returns a &#x60;200 OK&#x60; response code upon success, with the resource&#x27;s metadata in the response body.  If a &#x60;GET&#x60; request does not include a specific resource &#x60;id&#x60;, it is treated as a list request. The response usually returns a &#x60;200 OK&#x60; response code upon success, with an object containing a list of resources&#x27; metadata in the response body.  When reading resources, some common query parameters are usually available. e.g.: &#x60;&#x60;&#x60; v1/connections?limit&#x3D;25&amp;offset&#x3D;25 &#x60;&#x60;&#x60;  |Query Parameter|Type|Description| |---------------|----|-----------| |limit|integer|Maximum number of objects to fetch. Usually 25 by default| |offset|integer|Offset after which to start returning objects. For use with limit query parameter.|  ### Update  Updating a resource requires the resource &#x60;id&#x60;, and is typically done using an HTTP &#x60;PATCH&#x60; request, with the fields to modify in the request body. The response usually returns a &#x60;200 OK&#x60; response code upon success, with information about the modified resource in the response body.  ### Delete  Deleting a resource requires the resource &#x60;id&#x60; and is typically executing via an HTTP &#x60;DELETE&#x60; request. The response usually returns a &#x60;204 No Content&#x60; response code upon success.  ## Conventions  - Resource names are plural and expressed in camelCase. - Names are consistent between URL parameter name and field name.  - Field names are in snake_case. &#x60;&#x60;&#x60;json {     \&quot;name\&quot;: \&quot;string\&quot;,     \&quot;slots\&quot;: 0,     \&quot;occupied_slots\&quot;: 0,     \&quot;used_slots\&quot;: 0,     \&quot;queued_slots\&quot;: 0,     \&quot;open_slots\&quot;: 0 } &#x60;&#x60;&#x60;  ### Update Mask  Update mask is available as a query parameter in patch endpoints. It is used to notify the API which fields you want to update. Using &#x60;update_mask&#x60; makes it easier to update objects by helping the server know which fields to update in an object instead of updating all fields. The update request ignores any fields that aren&#x27;t specified in the field mask, leaving them with their current values.  Example: &#x60;&#x60;&#x60;   resource &#x3D; request.get(&#x27;/resource/my-id&#x27;).json()   resource[&#x27;my_field&#x27;] &#x3D; &#x27;new-value&#x27;   request.patch(&#x27;/resource/my-id?update_mask&#x3D;my_field&#x27;, data&#x3D;json.dumps(resource)) &#x60;&#x60;&#x60;  ## Versioning and Endpoint Lifecycle  - API versioning is not synchronized to specific releases of the Apache Airflow. - APIs are designed to be backward compatible. - Any changes to the API will first go through a deprecation phase.  # Summary of Changes  | Airflow version | Description | |-|-| | v2.0 | Initial releaase |  # Trying the API  You can use a third party client, such as [curl](https://curl.haxx.se/), [HTTPie](https://httpie.org/), [Postman](https://www.postman.com/) or [the Insomnia rest client](https://insomnia.rest/) to test the Apache Airflow API.  Note that you will need to pass credentials data.  For e.g., here is how to pause a DAG with [curl](https://curl.haxx.se/), when basic authorization is used: &#x60;&#x60;&#x60;bash curl -X POST &#x27;https://example.com/api/v1/dags/{dag_id}?update_mask&#x3D;is_paused&#x27; \ -H &#x27;Content-Type: application/json&#x27; \ --user \&quot;username:password\&quot; \ -d &#x27;{     \&quot;is_paused\&quot;: true }&#x27; &#x60;&#x60;&#x60;  Using a graphical tool such as [Postman](https://www.postman.com/) or [Insomnia](https://insomnia.rest/), it is possible to import the API specifications directly:  1. Download the API specification by clicking the **Download** button at top of this document 2. Import the JSON specification in the graphical tool of your choice.   - In *Postman*, you can click the **import** button at the top   - With *Insomnia*, you can just drag-and-drop the file on the UI  Note that with *Postman*, you can also generate code snippets by selecting a request and clicking on the **Code** button.  # Authentication  To be able to meet the requirements of many organizations, Airflow supports many authentication methods, and it is even possible to add your own method.  If you want to check which auth backend is currently set, you can use &#x60;airflow config get-value api auth_backend&#x60; command as in the example below. &#x60;&#x60;&#x60;bash $ airflow config get-value api auth_backend airflow.api.auth.backend.basic_auth &#x60;&#x60;&#x60; The default is to deny all requests.  For details on configuring the authentication, see [API Authorization](https://airflow.apache.org/docs/stable/security/api.html).  # Errors  We follow the error response format proposed in [RFC 7807](https://tools.ietf.org/html/rfc7807) also known as Problem Details for HTTP APIs.  As with our normal API responses, your client must be prepared to gracefully handle additional members of the response.  ## Unauthenticated  This indicates that the request has not been applied because it lacks valid authentication credentials for the target resource. Please check that you have valid credentials.  ## PermissionDenied  This response means that the server understood the request but refuses to authorize it because it lacks sufficient rights to the resource. It happens when you do not have the necessary permission to execute the action you performed. You need to get the appropriate permissions in other to resolve this error.  ## BadRequest  This response means that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). To resolve this, please ensure that your syntax is correct.  ## NotFound  This client error response indicates that the server cannot find the requested resource.  ## MethodNotAllowed  Indicates that the request method is known by the server but is not supported by the target resource.  ## NotAcceptable  The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation.  ## AlreadyExists  The request could not be completed due to a conflict with the current state of the target resource, meaning that the resource already exists  ## Unknown  This means that the server encountered an unexpected condition that prevented it from fulfilling the request.   # noqa: E501