DEV Community

mnmartinelli
mnmartinelli

Posted on

Experimenting with API microservices

Adding Wikipedia's API to my project

Wikipedia is a monolith in terms of knowledge of almost any subject. In my recent project, a user's location is displayed via Google Maps based off their IP address using Free Geo IP.

Since we are able to determine a user's city and state already, the project has expanded to incorporate wikipedia-query source. This web-component calls the Wikipedia API, receives JSON data back and is able to display information about a user's city or state.

Install/Setup

  1. Wikipedia-query needs to be added as a dependency in package.json. dependency
  2. Import into the project: import '@lrnwebcomponents/wikipedia-query';

Usage of location

//finding wiki based on city and state
<wikipedia-query search="${this.city}, ${this.state}"></wikipedia-query>

//finding wiki based on city
<wikipedia-query search="${this.city}"></wikipedia-query>

//finding wiki based on state
<wikipedia-query search="${this.state}"></wikipedia-query>
Enter fullscreen mode Exit fullscreen mode

Wikipedia-query can display more than location information and can be included in your project today. Please visit wikipedia-query documentation and Wikipedia Offical API documentation

Top comments (0)