A search engine results page, or SERP, is the page you see after entering a query into Google, Yahoo, or any other search engine. In addition to organic search results, search engine results pages usually include paid search and pay-per-click (PPC) ads plus additional generated information not directly related to the search. Wouldn’t it be nice to have a free, lightweight, easy-to-use SERP API built into your own app to give your users the ability to harness the immense power of search engines?
Table of Contents
How to add superb power to your apps with the absolute minimum of coding effort
Low code is where an IDE software really shines compared to nearly all other programming languages. In many ways, it was one of the very first ground-breaking systems to embrace low code as a philosophy right from the very first day it was released.
In this article, we will see how fast and easy it is to use RAD Studio and Delphi to create a Firemonkey multi-device application using the LowCode Wizard in addition to a REST client library to take advantage of SerpStack API and retrieve a JSON format response for Google SERP in real-time.
Using SerpStack API with RAD Studio’s low code capabilities is a smart way to produce applications in the modern world
SerpStack API offers instant access to live geocoding for global places and coordinates around the world. This is possible to be done for free (up to first 100 calls/month; no credit card required) and much more is available at very affordable prices and scalable to the use you make with no upfront commitments.
Our RAD Studio and Delphi applications will be able to call the API and request information based on the name of parameters you provide
How do I set up the SerpStack API?
Make sure you refer to SerpStack API website (https://SerpStack.com/) and and SignUp for the free Plan providing only your email and some basic information (no credit card required). Once you are in the website will redirect you to a Quickstart guide dashboard and your API Access Key will be provided. The Access Key unique, personal and is required to authenticate with the API. Keep it safe!
How do I call SerpStack API endpoints?
Now all we need to do is to call the API base URL (http://api.serpStack.com/) via a HTTP POST method with no JSON request body needed and some few requested parameters added to the URL address depending on the endpoint we choose to call. One can do that using REST Client libraries available on several programming languages.
SerpStack offers two API endpoints to choose from
- Search: Get SERP data for your search query
- Locations: Search locations supported by the API
Our demo will focus on the Search Endpoint but all the others follow similar logic but with different parameters passed. For a complete and detailed list of endpoints and its parameters make sure you refer to SerpStack Quickstart guide (https://serpStack.com/quickstart)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Search API Endpoint http://api.serpstack.com/search ? access_key = YOUR_ACCESS_KEY & query = mcdonalds // optional parameters: & engine = google & type = web & device = desktop & location = new york & google_domain = google.com & gl = us & hl = en & page = 1 & num = 10 & output = json // more parameters available please refer to the API Documentation (<a href="https://serpStack.com/documentation">https://serpStack.com/documentation</a>) |
What does the SerpStack API endpoint return?
After the call the main results will be a ton of information filtered based on the parameters you sent. The list below shows the result I got when I called the API informing “Embarcadero Delphi” as the “query” parameter. As you can see below the values for organic results include official Embarcadero website, Wikipedia, Youtube, Facebook, Linkedin, and more, along with related questions, definitions, and much more.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
{"request":{ "success":true, "total_time_taken":4.3, "processed_timestamp":1626963883, "search_url":"http://www.google.com/search?q=Embarcadero+Delphiu0026gl=usu0026hl=enu0026safe=0u0026num=10"}, "search_parameters":{"engine":"google","type":"web","device":"desktop","auto_location":"1","google_domain":"google.com","gl":"us","hl":"en","safe":"0","news_type":"all","exclude_autocorrected_results":"0","images_color":"any","page":"1","num":"10","output":"json","csv_fields":"search_parameters.query,organic_results.position,organic_results.title,organic_results.url,organic_results.domain","query":"Embarcadero Delphi","action":"search","access_key":"4f721293c84a5cf6914843107acf2560","error":{}}, "search_information":{"total_results":1210000,"time_taken_displayed":0.56,"detected_location":{},"did_you_mean":{},"no_results_for_original_query":false,"query_displayed":"Embarcadero Delphi","showing_results_for":{}}, "organic_results":[ {"position":1, "title":"Delphi: IDE Software Overview - Embarcadero", "snippet":"", "prerender":false, "cached_page_url":{}, "related_pages_url":{}, "url":"https://www.embarcadero.com/products/delphi", "domain":"www.embarcadero.com", "displayed_url":"https://www.embarcadero.com u203a Products"}, [...] {"position":4, "title":"Delphi (software) - Wikipedia","snippet":"","prerender":false,"cached_page_url":{},"related_pages_url":{},"url":"https://en.wikipedia.org/wiki/Delphi_(software)","domain":"en.wikipedia.org","displayed_url":"https://en.wikipedia.org u203a wiki u203a Delphi_(software)"}, [...] {"position":7, "title":"Embarcadero Technologies - YouTube","snippet":"","prerender":false,"cached_page_url":{},"related_pages_url":{},"url":"https://www.youtube.com/channel/UCMmsCQhkz-WlJ-IVBzPhbgA","domain":"www.youtube.com","displayed_url":"https://www.youtube.com u203a channel u203a UCMmsCQhkz-WlJ..."}, {"position":9, "title":"Embarcadero Technologies - Delphi - Home | Facebook","snippet":"","prerender":false,"cached_page_url":{},"related_pages_url":{},"url":"https://www.facebook.com/EmbtDelphi/","domain":"www.facebook.com","displayed_url":"https://www.facebook.com u203a ... u203a Brand u203a Software"}, {"position":10, "title":"Embarcadero Delphi | LinkedIn","snippet":"","prerender":false,"cached_page_url":{},"related_pages_url":{},"url":"https://www.linkedin.com/products/embarcadero-technologies-embarcadero-delphi","domain":"www.linkedin.com","displayed_url":"https://www.linkedin.com u203a products u203a embarcadero-tech..."} ], [...] "related_questions":[ {"question":"Who uses Embarcadero Delphi?", "answer":"","title":"","url":"/search?hl=enu0026gl=usu0026q=Who+uses+Embarcadero+Delphi?u0026sa=Xu0026ved=2ahUKEwiP8qDh8PbxAhWmMlkFHY6_AfYQzmd6BAgREAs","displayed_url":""}, {"question":"What is the difference between RAD Studio and Delphi?", "answer":"","title":"","url":"/search?hl=enu0026gl=usu0026q=What+is+the+difference+between+RAD+Studio+and+Delphi?u0026sa=Xu0026ved=2ahUKEwiP8qDh8PbxAhWmMlkFHY6_AfYQzmd6BAgREA8","displayed_url":""}, [...] |
This is what those search results look like
How do I connect my applications to SerpStack API?
Once you have followed basic steps to set up the SerpStack API we need to make sure we are able to connect and communicate with it before we start writing some code.
RAD Studio Delphi and C++Builder make it very easy to connect to APIs as you can you REST Debugger to automatically create the REST components and paste them into your app.
In Delphi, all the job is done using 3 components to make the API calls. They are the TRESTClient, TRESTRequest, and TRESTResponse. Once you connect the REST Debugger, successfully, copy and paste the components,, you will notice that the API URL is set on the BaseURL of TRESTClient. On the TRESTRequest component, you will see that the request type is set to rmPOST, the ContentType is set to ctAPPLICATION_JSON, and that it contains one request body for the POST.
Run your RAD Studio Delphi and on the main menu click on Tools > REST Debbuger. Configure the REST Debugger as follows marking the content-type as application/json, and adding the POST url, the JSON request body and the API key you created. Once you click the Send Request button you should see the JSON response, just like we demonstrated below.
Use the RAD Studio REST Debugger to easily interface with REST web services
How do I build a Firemonkey Multidevice (Windows/MacOS desktop or Android/iOS mobile) application using the SerpStack API?
Low code app development is increasingly popular today, and for a good reason: it speaks to the demand for software paired with the difficulty of creating it. In many ways, Delphi led the low code revolution: RAD, where you build software by connecting components in a visual designer, is low code. The key with many low code solutions is extensibility: low code which cannot be extended to a traditionally coded app has a hard upper limit of functionality. If you’re a technology adviser, you do not want to recommend something which will limit your client or company. The best development solutions that target low code provide an avenue to grow and extend. In this too, Delphi excels.
Until recently in Delphi you still had to create a new project and create the forms or screens yourself – no matter how little code you may have to write to get powerful functionality when you did. This is something we’ve now addressed with an addon to 10.4.2. Run your RAD Studio Delphi and on the main menu click on Tools > GetIt Package Manager. In GetIt for 10.4.2 and later search for “Low Code App Wizard for FireMonkey”, our technology for cross-platform applications.
Install the FireMonkey App Low Code Wizard via the GetIt Package Manager
Now that you have installed Low Code App Wizard for FireMonkey and that you were able to sucessfully configure and test your API calls on the REST Debbuger, go back to the REST Debbuger and click the Copy Components button. Open RAD Studio Delphi and on the main menu click File > New> Multi-Device Application Delphi, select the Firemonkey Template App as shown below and follow some simples Wizard steps to create your Low Code application.
How to create an app using the Low Code app wizard with just a few clicks
The result will be a fully functional cross-platform application, which already contains basic functionality that every mobile app will need — you can run and use the app as is — and hooks to build more, plus demonstrates application development best practices with a very clean extensible design to add more screens with low code, plus a set of tests to ensure your app remains high quality as you customise it.
Can the RAD Studio Low Code Wizard apps be configured?
The app that Delphi builds for you is configurable through the wizard and you can choose any set of the following:
- User accounts: sign up, sign in, and a profile screen, with hooks for your own authentication
- Settings screen (where you can change the app theme (light or dark), plus some example settings you can reuse or extend)
- Contacts screen
- Terms of Use, About, and Privacy policy screens, easily configurable for your own data
- A database layer: using Interbase, store data in your app
- An example new screen you can use as a template or example for adding new functionality
As you can see the Wizard saves you a lot of time as it creates a complete project with many forms ready for you to implement the code. Open the recently created NewFormFrame and hit Ctrl+V in order to paste the components you copied from REST Debbuger. This acction will result in three components added to the the form RESTClient1, RESTRequest1 and RESTResponse1.
Adding some extra button click code to our low code app
Now we will simply add very simple code to a TButton OnClick event to make sure every thing is configured correctly and voila! In five minutes we have made our very first call to SerpStack API and we are able to receive JSON response for whatever parameter we want.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
procedure TNewFormFrame.Button1Click(Sender: TObject); begin inherited; memo1.Lines.text := ''; RESTClient1.ResetToDefaults; RESTClient1.Accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,'; RESTClient1.AcceptCharset := 'UTF-8, *;q=0.8'; RESTClient1.BaseURL := 'http://api.serpStack.com/v1/forward'; RESTClient1.HandleRedirects := True; RESTClient1.RaiseExceptionOn500 := False; //here is were we pass the access_key and the additional parameters RESTRequest1.Resource := Format('?access_key=%s&query=%s', [edit1.Text, edit2.Text]); RESTRequest1.Client := RESTClient1; RESTRequest1.Response := RESTResponse1; RESTRequest1.SynchronizedEvents := False; RESTResponse1.ContentType := 'application/json'; RESTRequest1.Execute; memo1.Lines.text := RESTResponse1.Content; end; |
The sample application features a TEdit as a place to paste in the access key and additional TEdit for each parameter, a TMemo to display the JSON results of the REST API call. Now you have every thing you need in order to interate with the response data and make your application process the information and present it visually in the way it better suits your needs!
Here are the results of our API calls, running in our app
In this blog post we’ve seen how to sign up for the SerpStack API in order to get instant access to structured and readable SERP data. We’ve seen how to use the RAD Studio REST Debugger to connect to the endpoint and copy that code into a real application. And finally we’ve seen how easy and fast it is to use RAD Studio Delphi and the Low Code App Wizard for FireMonkey to create a real Multidevice (Windows/MacOS desktop or Android/iOS mobile) application which connects to the API and retrives the data ready for you to iterate!
Where can I download an example of using the SerpStack API?
Head over and download the full example code from here: https://github.com/checkdigits/SERPApp_MediaStackAPI_example
RAD Studio aims to make coding apps of all types as easy as possible with the minimum amount of effort. Why not download a trial copy to today and see how it can help you turn your ideas into reality?
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition