Recent

Author Topic: Rapidapi (https://rapidapi.com/)  (Read 363 times)

alaa123456789

  • Full Member
  • ***
  • Posts: 229
  • Try your Best to learn & help others
    • youtube:
Rapidapi (https://rapidapi.com/)
« on: July 02, 2022, 06:04:17 pm »
Hi ,
i was searching all the day to find a way how to use https://rapidapi.com/ in lazarus
this website has many useful free API's , for example https://rapidapi.com/dmisdm/api/youtube-dl4
it has implantation in many different programming languages but not in pascal , anyone could help with this?

thanks

MarkMLl

  • Hero Member
  • *****
  • Posts: 4769
Re: Rapidapi (https://rapidapi.com/)
« Reply #1 on: July 02, 2022, 07:32:02 pm »
What does it do? I think an introduction is in order rather than expecting people to invest time in looking at an unknown website.

What language is the standard API in? If it's C (as distinct from C++ with object oriented stuff) FPC has a conversion tool which gets .h files mostly right.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

paweld

  • Sr. Member
  • ****
  • Posts: 417
Re: Rapidapi (https://rapidapi.com/)
« Reply #2 on: July 02, 2022, 08:01:31 pm »
Code: Pascal  [Select][+][-]
  1. uses
  2.   fphttpclient, fpopenssl, opensslsockets, httpprotocol;
  3.  
  4. procedure TForm1.Button1Click(Sender: TObject);
  5. var
  6.   hc: TFPHttpClient;
  7.   api: String = 'https://youtube-dl4.p.rapidapi.com/';     //rapidapi youtube-dl
  8.   key: String = '***********************';                 //your rapidapi key
  9.   host: String = 'youtube-dl4.p.rapidapi.com';             //rapidapi youtube host
  10.   outjson: String = '';
  11. begin
  12.   hc := TFPHttpClient.Create(nil);
  13.   hc.AllowRedirect := True;
  14.   hc.AddHeader('X-RapidAPI-Key', key);
  15.   hc.AddHeader('X-RapidAPI-Host', host);
  16.   try
  17.     outjson := hc.Get(api + '?url=' + HTTPEncode('https://www.youtube.com/watch?v=lNK8EIoNJS8'));
  18.   finally
  19.     hc.Free;
  20.   end;
  21. end;
Best regards
paweld
---
Lazarus trunk / FPC stable

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 10176
  • FPC developer.
Re: Rapidapi (https://rapidapi.com/)
« Reply #3 on: July 02, 2022, 09:00:27 pm »
Seems that RapidAPI is simply a rental marketplace for web apis. The marketplace aspect seems to be way larger than the coding side of things.

But they have a simple generator for the simplest of APIs in multiple languages, so the simplest would be to ask them to add Delphi and/or lazarus to the languages.

alaa123456789

  • Full Member
  • ***
  • Posts: 229
  • Try your Best to learn & help others
    • youtube:
Re: Rapidapi (https://rapidapi.com/)
« Reply #4 on: July 04, 2022, 07:26:55 pm »
What does it do? I think an introduction is in order rather than expecting people to invest time in looking at an unknown website.

What language is the standard API in? If it's C (as distinct from C++ with object oriented stuff) FPC has a conversion tool which gets .h files mostly right.

MarkMLl

it is providing useful api's you could use it in the applications for example covid19 api
anyway thanks for the guys who has replied already with example so everybody in this forum could get benefit from it

regards

alaa123456789

  • Full Member
  • ***
  • Posts: 229
  • Try your Best to learn & help others
    • youtube:
Re: Rapidapi (https://rapidapi.com/)
« Reply #5 on: July 04, 2022, 07:27:31 pm »
Code: Pascal  [Select][+][-]
  1. uses
  2.   fphttpclient, fpopenssl, opensslsockets, httpprotocol;
  3.  
  4. procedure TForm1.Button1Click(Sender: TObject);
  5. var
  6.   hc: TFPHttpClient;
  7.   api: String = 'https://youtube-dl4.p.rapidapi.com/';     //rapidapi youtube-dl
  8.   key: String = '***********************';                 //your rapidapi key
  9.   host: String = 'youtube-dl4.p.rapidapi.com';             //rapidapi youtube host
  10.   outjson: String = '';
  11. begin
  12.   hc := TFPHttpClient.Create(nil);
  13.   hc.AllowRedirect := True;
  14.   hc.AddHeader('X-RapidAPI-Key', key);
  15.   hc.AddHeader('X-RapidAPI-Host', host);
  16.   try
  17.     outjson := hc.Get(api + '?url=' + HTTPEncode('https://www.youtube.com/watch?v=lNK8EIoNJS8'));
  18.   finally
  19.     hc.Free;
  20.   end;
  21. end;

thanks paweld , will give it  a try

 

TinyPortal © 2005-2018