Midpoint is now live on Filecoin Hyperspace!

Read from a Wikipedia Article with Polygon

Jan 30
Jonathan Zwiebel
Read from a Wikipedia Article with Polygon

The vast database of information contained within the Wikipedia API has proven to be a valuable resource for Polygon developers seeking to integrate it into their decentralized applications. This API enables smart contracts to access current information on a wide range of topics without incurring additional infrastructure or node-related costs. In this tutorial, we'll construct a contract that leverages the Wikipedia API to retrieve article summaries. By establishing a bridge between the contract and the API, we'll enable smooth and efficient access to the extensive knowledge base available on Wikipedia.

Load a Template Midpoint
Midpoint Templates Page

Login to your Midpoint dashboard and create a new midpoint. Select the “Request an Article with Wikipedia” template. This pre-configured template midpoint has already been set up to make requests to the Wikipedia API for article summaries. All the necessary configurations have been completed, so all you need is a deployed contract that can make these requests on your behalf.

Deploy Contract
Use This Midpoint Page

To deploy a contract with the “Use This Midpoint” page, select your desired chain and the Simple Storage Contract. This will generate a contract ready for deployment. Copy that contract into your favorite editor and deploy.

Test Midpoint Request Function in Solidity
This function makes the call to our midpoint
Callback function in solidity
This function is called when our midpoint gets a response

If you would like to learn more about the contents of this auto-generated contract, please refer to https://docs.midpointapi.com/midpoint-documentation/concepts/misc/the-use-this-midpoint-page for further information and details.

Publish Your Midpoint

Our midpoint is now ready to go. Hit the Publish button and our midpoint will begin listening for requests.

A Live Midpoint
Our midpoint is live
Make a Request

Now that our midpoint is configured and live we can send a request to it. Simply invoke the testMidpointRequest function and pass in the title of the article you want to summarize.

Transacting to the Wikipedia Midpoint
Get the summary for the article on Turing Machines

Head to the Requests tab to follow your request live.

Requests page outbound transaction
Our midpoint has picked up the request and is making a call to the Wikipedia API
Requests page response
Our midpoint successfully posted the response back through the callback function

Our request has been fulfilled! Here's the response transaction putting the article summary back on chain.


Congratulations! You have just created a smart contract that is capable of retrieving the summary of a Wikipedia article through the use of the Wikipedia API and a Midpoint! Although this contract was just a basic example, it serves as a great source of inspiration for future projects. If you develop anything interesting, be sure to share it with us by reaching out at Twitter! evelopers are leveraging the power of Midpoint to connect their contracts to numerous off-chain endpoints, including DocuSign, Google Cloud, Slack, Salesforce, Twitter, and Discord. If you are a developer seeking to integrate your smart contract with off-chain services join the conversation on Discord and check out our comprehensive documentation.

More articles