FOR 2.0.x PLEASE GO TO THE 2.0.x BRANCH
An Angular module wrapping the Airtable API
Feel free to take a look at the DEMO.
Install via npm:
npm install ngx-airtable --save
or install via yarn
yarn add ngx-airtable
import {NgModule} from '@angular/core';
import {NgxAirtableModule} from 'ngx-airtable';
import {HttpClientModule} from '@angular/common/http';
@NgModule({
imports: [
HttpClientModule,
NgxAirtableModule.forRoot()
],
bootstrap: [AppComponent]
})
export class AppModule {
}
If you want to have a global configuration you can provide an option config when importing the module:
NgxAirtableModule.forRoot({ apiKey: 'YOUR_API_KEY' })
The API key is the only configuration value which has to be provided (either globally or by usage (using configure()
)).
The endpoint url and the api version are provided with the following default values:
endpointUrl: 'https://api.airtable.com'
apiVersion: 0
If you want to you can overwrite them (either globally or by usage (using configure()
).
This module is providing the same functionality as the official Airtable JavaScript Library airtable.js as of v0.5.0.
configure(opts: AirtableConfiguration): Airtable
: provides the configuration or overrides the global configuration used to connect to the Airtable APIbase(baseId: string): Base
: creates a new Base instance identified by id
options: AirtableConfiguration
: provides an accessor for the options object passed to the configure method
table(tableOpts: {tableName?: string; tableId?: string;}): Table
: creates a new Table instance identified by name or id
baseId: string
: provides an accessor for the Base's idairtable: Airtable
: provides an accessor for the overlaying Airtable instance
find(id: string): Observable<any>
: fetches a record identified by idselect(params?: SelectParams): Query
: creates a new Query instance with the given parameterscreate(entityData: any): Observable<any>
: creates a new entityupdate(id: string, entityData: any): Observable<any>
: updated an entity identified by id with the given datadestroy(id: string): Observable<any>
: deletes an entity identified by idreplace(id: string, entityData: any): Observable<any>
: replaces an entity identified by id with the given data
base: Base
: provides an accessor for the overlaying Base instanceurlEncodedNameOrId: string
: provides an accessor for the url-friendly encoded Table name or id
firstPage(): Observable<any>
: fetches the first page (ifpageSize
is omitted => max. 100 records)eachPage(): Observable<any>
: fetches each page (all records but each page is emitted separately)all(): Observable<any>
: fetches all pages and emits all records at once
apiKey?: string
: provides the API key to access AirtableendpointUrl?: string
: the API endpoint to hit. You might want to override it if you are using an API proxy (e.g. runscope.net) to debug your API callsapiVersion?: number
: the API version
Extends Table
The LinkedTable
does the same - according to data fetching - as the Table
but it can handle entity relations while fetching.
Take a look at the DEMO.
What the LinkedTable
is not capable of are entity modifications - create, update, delete.
static fromTable(origin: Table, links: Link[]): LinkedTable
: creates a new LinkedTable instance using the provided origin Table and the given linksfind(id: string): Observable<any>
: fetches a record identified by id with its related entitiesselect(params?: SelectParams): LinkedQuery
: creates a new LinkedQuery instance with the given parameters
Extends Query
The LinkedQuery
does the same - according to data fetching - as the Query
but it can handle entity relations while fetching.
Take a look at the DEMO.
firstPage(): Observable<any>
: fetches the first page (ifpageSize
is omitted => max. 100 records) with its related entitieseachPage(): Observable<any>
: fetches each page (all records but each page is emitted separately) with its related entitiesall(): Observable<any>
: fetches all pages and emits all records at once with its related entities
fields?: string[]
: limits the fetched fields per recordfilterByFormula?: string
: a formula used to filter the recordsmaxRecords?: number
: limits the maximum record countpageSize?: number
: The number of records returned in each request. Must be less than or equal to 100. Default is 100.sort?: SortParam[]
: specifying sorting rules by field and directionview?: string
: the name or id of the view to fetch
field: string
: the name of the field to sortdirection: SortDirection
: the direction to sort
type SortDirection = 'asc' | 'desc'