Menu

GeoDB Cities API - Find Cities For Your Criteria | Wirefree Thought

Integrating with Angular

GeoDB Angular SDK

The easiest way to integrate the GeoDB service into your Angular (5.0+) 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_MASHAPE_KEY,
          serviceUri: https://wft-geo-db.p.mashape.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 main disadvantage is that, 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.