Menu

GeoDB Cities API

Integrating with Angular

GraphQL

Here are some options for executing GraphQL queries from Angular:

REST

GeoDB Angular SDK

For the REST API, the easiest way to integrate the GeoDB service into your Angular app is by using the available client SDK

  1. cd
     into your Angular project root.
  2. npm install wft-geodb-angular-client@latest --save
  3. Update your AppModule.ts as follows:
    @NgModule({
      declarations: [
        ...
      ],
      imports: [
        ...
        GeoDbModule.forRoot({
          apiKey: YOUR_RAPIDAPI_KEY,
          serviceUri: https://wft-geo-db.p.rapidapi.com
        })
      ],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
  4. In your Typescript class:
    constructor(private geoDbService: GeoDbService) { }
    
  5. Later on, in some method:
    this.geoDbService.someMethod({
        someRequestParam: value,
        someOtherRequestParam: value,
        ...
      })
      .subscribe(
        (response: GeoResponse) => {
            // Do your thing!
          }
      )
    
  6. Explore the Client SDK, including source code and a cookbook of examples.

RapidAPI Node.js SDK

In addition to our homegrown (and recommended) SDK, you may also opt to use the RapidAPI version.

The advantage of using RapidAPI's variant is you can use it to consume any API available on that platform. Also, if your Node.js app isn't based on Angular, you will again have to use this version.

The disadvantage is, because it serves as a lowest common denominator to all possible APIs, it's not tailored to the GeoDB domain and is not as user-friendly.