Unknown macro: {next_previous_links}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Introduction

This sample demonstrates how to subscribe to a published API and consume its functionality using the API Store Web application. We use the Wikipedia API here.

Building the Sample

Execute the steps in Samples Setup. When you are done, you will have the API Manager started and the relevant scripts run to create user accounts for API Publisher and API Store.

The scripts used for this sample do not work in Windows. Support for Windows will be added in an upcoming release.

Executing the Sample

  1. If you haven't done so already, start the API Manager and log in to the API Publisher(http://localhost:9763/publisher) using credentials provider1/provider1.
  2. There are no APIs created yet. To create one, run <APIM_HOME>/samples/WikipediaAPI/APIPopulator.sh (on Linux) or <APIM_HOME>/samples/WikipediaAPI/APIPopulator.bat (on Windows).
  3. Refresh the API Publisher to see the Wikipedia API created.
  4. Click on the API, go to its Lifecycles tab and publish the API by selecting its life cycle stage as PUBLISHED.
  5. You can now access Wikipedia through this newly-deployed API. Log in to the API Store (http://localhost:9763/store) using credentials subscriber1/subscriber1.
  6. Select the Applications tab at the top of the page, and create a new application. Provide any name you like.
  7. Select the APIs tab at the top of the page, select the WikipediaAPI API and subscribe to it using the newly-created application.
  8. Go to the My Subscriptions tab and select your application. Click the Generate button associated with the production system to obtain an application access token.
  9. You are now ready to invoke the API. Copy and paste following into a new console and execute it. Be sure to replace the string '9nEQnijLZ0Gi0gZ6a3pZICktVUca' with the application access token you obtained earlier.

    curl -H "Authorization :Bearer 9nEQnijLZ0Gi0gZ6a3pZICktVUca" "http://10.100.5.20:8280/wikipedia/1.0.0?format=json&action=query&titles=Main Page&prop=revisions&rvprop=content"
  10. You must see the JSON result from the Wikipedia API on you console. For example,

    {"query":{"pages":{"5982813":{"pageid":5982813,"ns":0,"title":"MainPage","revisions":[{"contentformat":"text/x-wiki","contentmodel":"wikitext", "*":"#Redirect [[Main Page]]\n\n{{Redr|mod|rcc}}"}]}}}}... 

    See http://www.mediawiki.org/wiki/API:Main_page for more information about the Wikipedia API. You can try out various API actions and features similar to step 9.

  • No labels