Author Topic: Spriggsy's API Collection  (Read 2944 times)

0 Members and 1 Guest are viewing this topic.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 554
  • If you're API and you know it clap your hands
    • My GitHub
Spriggsy's API Collection
« on: August 18, 2020, 01:34:50 PM »
At the request of some members here is a collection of my API programs' source codes so far. I'll update this post each time I make a new API and will add it to the zip folder.

This package contains API usage for REST, HTTP, HTTPS, WinAPI (Shell32, User32, Kernel32, etc.), and Cross-platform C++ Libraries. Each one is unique in some way.

Attached is a 7-zip folder containing the source codes for each.

Inside the folder is:

Quote
REST, HTTP, HTTPS API using CURL, urlmon, _OPENCONNECTION (Windows)
Address Validation API (smartystreets.com)
Currency Exchange Rate API (exchangerate-api.com)
Profanity Check/Censor API (purgomalum.com)
Phone Number Verification API (apilayer.com)
Insult Generator API (evilinsult.com)
Sentiment API (sentimapi)
Breaking News API (newsapi.org)
Kitten Image Replacer API (placekitten)
Image from Hash API (robohash)
Screenshot of Webpage API (screenshotlayer.com)
NASA Astronomy Pic of the Day API (nasa.gov) Updated 08/20/2020 Updated with source I had posted elsewhere. Much more efficient code.
DCUO Census API (daybreakcensus)
Online Movie Database API (omdb) Updated 10/18/2020 (Using Wininet WinAPI for internet connectivity)
Lyrics API (lyrics.ovh)
Weather API using GeoLocation from IP Address (various API vendors) Added 08/18/20 since it was missing from collection
Owlbot Dictionary API Added 08/19/2020
Genderize API Added 09/20/2020
QR Tag API Added 09/20/2020
Gravatar Image from email address hash API (gravatar, wordpress) Updated 10/18/2020 (Using Wininet WinAPI for internet connectivity)

WinAPI libraries using Kernel32, User32, Advapi32, Wininet, etc. (Windows)
UuidCreate, UuidCreateSequential, UuidHash (rpcrt4 ,Wininet) UUID Creation and MAC Address Lookup (uuidtools and macvendors.com) Updated 10/17/2020
SHFileOperation (Shell32) Added 09/22/2020
GetComputerName, GetUsername (Kernel32 , Advapi32) Added 09/22/2020
FindExecutableA (Shell32) Added 09/26/2020
ShellAboutA (Shell32) Added 09/26/2020
mciSendStringA (WINMM) Record and playback audio (updated source with ffmpeg waveform drawing.) Added 09/26/2020
DoEnvironmentSubstA, GetEnvironmentVariableA, ExpandEnvironmentStringsA (Shell32) (Works similarly to ENVIRON$ but with some extra functionality and speed. Added 09/26/2020
ExractIcon, DrawIcon (Shell32 , User32) Added 09/27/2020
SetWindowPos, GetForegroundWindow (User32) Credit to Pete and visionmercer, original post here: https://www.qb64.org/forum/index.php?topic=1365.msg105588#msg105588 Added 09/27/2020
AnimateWindow (User32) Added 09/30/2020
FlashWindow/FlashWindowEx (User32) Added 10/02/2020
capCreateCaptureWindow (Avicap32) Records webcam footage to AVI file Added 10/02/2020
OpenProcess, TerminateProcess (Kernel32) Kill process by name or PID Added 10/05/2020
MessageBeep (User32) Plays WAV audio for common message sounds Added 10/05/2020
OpenClipboard, GetClipboardData (User32) Added 10/07/2020
GetBinaryType (Kernel32) Added 10/09/2020
GetTempPath, GetTempFileName (Kernel32) Added 10/09/2020
GetDateFormat, GetCurrencyFormat (Kernel32) Added 10/09/2020
OpenProcess, ReadProcessMemory, WriteProcessMemory (Kernel32) Added 10/16/2020 (Peeping Tom, a powerful PEEK/POKE library for QB64)
XInputGetState, XInputSetState, XInputGetBatteryInformation (Xinput1_4) Tests an XInput enabled controller Added 10/26/2020
(Wininet) Various Wininet FTP functions for uploading, downloading, directory listing, etc. Too many functions to write here. Largest library yet. Added 11/17/2020

Cross-Platform Libraries (Windows, Macintosh, and Linux)
pipecom (pipecom) Header file that pipes console output to QB64. Win (using WinAPI), Mac, and Linux (using C libraries). Added 10/26/2020
encodeBase64, decodeBase64 (Crypt32, base64 (Linux and Mac)) Added 11/05/2020

 
https://mega.nz/file/Tn42gbRK#70zC0etdyZZc6u0QRNrvGGbVowwZn-Bo-oLWJv6AU-c Link to a 7zip folder containing just ffmpeg for the mciSendStringA waveform functionality

Note: All libraries with the exception of the Cross Platform libraries are written on and for Windows 10 64 bit (and should also work with 32 bit). Now that I am using WSL2 (Windows Subsystem for Linux) I am also developing libraries for Linux. See here for a post about installing WSL2 on Windows 10 to use Linux on your machine: https://www.qb64.org/forum/index.php?topic=3152.msg124219#msg124219

Enjoy
« Last Edit: Yesterday at 02:04:50 AM by SpriggsySpriggs »

Offline bplus

  • Forum Resident
  • Posts: 5525
  • B+ Knot again!
Re: Spriggsy's API Collection
« Reply #1 on: August 18, 2020, 03:56:11 PM »
Good to see these in single package.

One of these days (yeah sure, well maybe) I hope to sit down and see how you put these together generally.

It's smart to use Windows resources, that makes you resourceful! ;-)

Offline Waltersmind

  • Newbie
  • Posts: 24
    • The Joyful Programmer
Re: Spriggsy's API Collection
« Reply #2 on: August 18, 2020, 08:45:09 PM »
@spriiggsySpriggs, when did you get ominous emails? If it was in the last several weeks, I can tell you for a fact that it was not CoderHunter. Also, I have spoken with him about this accusation, and he guarantees me it was not him.

As I have mentioned to other people in this community, CodeHunter is not the only one from this community who is angry with the community, and that I have been working with CodeHunter ever since this mess started to get to realize it is unhealthy for him to continue this anger to this community for what was done to  him, and I have given him a new home where he can finally be part of a community who appreciates him.

All I ask is that you people stop accusing him of things without being 100% positive, because like I said, CodeHunter is not the only one who is unhappy with this community. He has calmed down quite a bit and no longer cares about any of this anymore and has moved on, which is why he will be leaving the IRC.

On a final note, he is now part of a bigger and better project, and has no need for this one anymore. He is now involved with ModernBASIC 128, which myself and a couple of other powerful developers are working on, so he has no time wallering in anger.

We have a category for ModernBASIC 128 on my Discord server with multiple channels where we are planning out the project, and everything is for the public to see.

I don't get a lot of time at the moment to constantly add stuff because I am gone between 4:00pm and 4:30am everyday, as I work from 5:00pm to 3:30am Monday through Friday and sometimes Saturday.

Offline bplus

  • Forum Resident
  • Posts: 5525
  • B+ Knot again!
Re: Spriggsy's API Collection
« Reply #3 on: August 18, 2020, 09:15:36 PM »
Walter, it's nice to hear from you again!

Online FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2495
  • LET IT = BE
    • QB64.org
Re: Spriggsy's API Collection
« Reply #4 on: August 18, 2020, 09:35:26 PM »
Daniel Dionne who goes online by Code Hunter, among other nicknames, has made public death threats to me and even gone on to mention my family and child in hate messages sent via several platforms.

All because he was denied the right to break our terms of service. Which we then gave up in his case because of the annoyance.

He was not welcome anymore for disrespectful behavior and he is now forever not welcome anymore due to the death threats. I have not taken it to authorities yet, especially given his personal condition and physical location. I'm keeping the records though.

Mentioning him won't be tolerated any longer. Defending him on our platform is not welcome.

Anyone else from the list of haters Walter mentions, himself included, are welcome to express themselves elsewhere.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 554
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #5 on: August 18, 2020, 09:41:30 PM »
Updated source code for OMDB API with scratch made HTTP GET statement. Works much faster than urlmon and would allow for compatibility with Linux (except for the image download, which uses HTTPS and so requires urlmon)

Offline Waltersmind

  • Newbie
  • Posts: 24
    • The Joyful Programmer
Re: Spriggsy's API Collection
« Reply #6 on: August 18, 2020, 09:54:50 PM »
Bplus, thank you. I'm actually around quite a bit here and on QB64's Discord server, but I dont socialize very much anymore. I'm mostly on my Discord server now helping people and writing content for ModernBASIC 128. We currently have 110 members there and growing.

I'm in the process of expanding my communities, building my new websites, and working with some other developers on creating ModernBASIC 128, which will be a multi-language transpiler, similar to the way GCC is. Right now there will be three languages wrapped into one: QBasic, QB64, and of course ModernBASIC 128.

All of this is either mentioned on my Discord server, or will be soon enough. I have nothing to hide and everything to share. This is a community project so my word is not final.

My schedule doesn't give me very much time for personal life due to all the constant overtime I have to do at my new job. I am working almost 50 hours a week.
« Last Edit: August 18, 2020, 10:01:05 PM by Waltersmind »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 554
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #7 on: August 18, 2020, 10:17:29 PM »
@Waltersmind , I'd rather you promote this other language and server in "Off-Topic" so it doesn't muddle up this thread.

Offline bplus

  • Forum Resident
  • Posts: 5525
  • B+ Knot again!
Re: Spriggsy's API Collection
« Reply #8 on: August 18, 2020, 10:44:59 PM »
@SpriggsySpriggs

Is there one of these that is most general or best to start a study of?

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 554
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #9 on: August 18, 2020, 10:53:28 PM »
Updated 08/18/20 with source code for Weather API using Geolocation from IP address.

Offline bplus

  • Forum Resident
  • Posts: 5525
  • B+ Knot again!
Re: Spriggsy's API Collection
« Reply #10 on: August 18, 2020, 10:59:05 PM »
@SpriggsySpriggs

Well I just tried NASA pic of day and it seems to hang on a big black screen.

Have you checked the code from the package? Why are all the bas files double titled with - Merged.BAS?

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 554
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #11 on: August 18, 2020, 10:59:58 PM »
Is there one of these that is most general or best to start a study of?
@bplus I'd take a look at the weather API. It uses several different API endpoints. I'll have to eventually update it with my JSON parsing functions but for a starter it should be good. Gives a nice look at how each one is slightly different and how I make them work together. I'd also recommend you look at the OMDB API and News API so you can see how I use my JSON parsing functions to read the responses. The OMDB API uses both a scratch made GET statement using OPENCLIENT and urlmon to download the image response so check that out for doing HTTP (HTTP only in scratch made GET. HTTPS can be used in urlmon and CURL) GET statements. Sentim API uses CURL to pass custom headers so check that one out for HTTPS that uses custom headers.
« Last Edit: August 18, 2020, 11:20:34 PM by SpriggsySpriggs »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 554
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #12 on: August 18, 2020, 11:04:33 PM »
@SpriggsySpriggs

Well I just tried NASA pic of day and it seems to hang on a big black screen.

Have you checked the code from the package? Why are all the bas files double titled with - Merged.BAS?
@bplus Nothing is missing in the package. The issue isn't from my code, it's because they (NASA) run on UTC time so they are in the next day. When the API requests "today's" image it is actually going to be using tomorrow's date since in UTC time right now it is 3 AM tomorrow and the picture for tomorrow doesn't exist yet. Run it in the morning (I'd say no earlier than 6 AM) and you will see an image. Something might be amiss with my API key. It could be expired for non-usage. I'll have to check. As for the Merged part of each source code's title, I mentioned in the original post I used Source Merger to grab all my $INCLUDEs so as to not have any dependencies missing and I didn't change the file names so I remember that I did already merge them and to keep doing so.
« Last Edit: August 19, 2020, 10:59:13 AM by SpriggsySpriggs »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 554
  • If you're API and you know it clap your hands
    • My GitHub
Re: Spriggsy's API Collection
« Reply #13 on: August 19, 2020, 10:58:36 AM »
@bplus I found the issue. It isn't necessarily my code or my API key. It's because they didn't have an image in the JSON response. They just had a youtube link. There was no image to load. Last night it was because it was UTC time. Today it is because they didn't respond with an image. Nothing I can do about it. I assumed they would always have an image link.

Offline bplus

  • Forum Resident
  • Posts: 5525
  • B+ Knot again!
Re: Spriggsy's API Collection
« Reply #14 on: August 19, 2020, 11:06:30 AM »
Yes, thanks all the others I tried worked. Figures I pick the one that doesn't to start with. EDIT: Don't mean to imply it's on Spriggys end with his code. NASA? another government agency who only works under very certain conditions, you would think Pic of the Day would be posted all day or until they come back from holiday and had another one to replace it. :)

If you filter the Insult app through the Profanity app, it would have nothing to say ;-))

Man the terminology is like from a different world and language. But time to try something new, for me, now that I have String Math mostly off my bucket list.
« Last Edit: August 19, 2020, 11:15:17 AM by bplus »