The use of APIs allows us to access a set of functions and methods that we would otherwise have to develop ourselves, which would cost time. In the case of the Apicultur APIs, we rely on a number of methods, all of which are linguistic, that make our lives easier in this field.
However, the lack of knowledge sometimes makes it difficult to use a particular resource, and a hand-made example makes life easier. Anyway, without further ado, let’s explain how we can access the Apicultur APIs, collect data and use them with C# and Visual Studio 2012.
We have done a little project that we’ve called Cruzaletras, which consists of a small application that allows us to obtain combinations for our games of Scrabble, Intelect and Crosswords…using the ApiculturSubPalabras v.1.0.0 API.
Using XAML or the blend, we have created a “TextBox” (x:Name=”letters”) in order to add the word we want to search for, a “Button” (x:Name=”submit”) in order to send the search and a un “TextBlock” (x:Name=”results”) in order to show the results.
Once the design is created we can continue. First of all, you need an API Key from Apicultur, both for testing and for final usage. To do this you can go to “1. Creation of a new Apicultur account and subscription” at the beginning Improve your database search results with Apicultur, where it explains clearly and concisely how to obtain it.
Once this is done and once you have our “Production Access Token” we can continue.
Our program has 4 functions:
1.- StartWebRequest: Create an HttpWebRequest and collect the data, calling FinishWebRequest in order to process them.
4.- submit_Tap: And finally we have to call the StartWebRequest function. The function will be called when you press the “submit” button.
In our case we have also created a Word class in order to process the JSON, it’s not necessary but recommended.
And that’s all. We can write a word in the TextBox, click OK and in a few moments we will have our results.
Author: Javi Barrera, Winner of the Iberic APIdays Mediterranea Hackathon (Categoría APIcultur)