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

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Spriggsy's API Collection
« on: August 18, 2020, 01:34:50 pm »
This collection is now hosted on GitHub but will show updates to the package here as well.

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.

Inside the collection 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 (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 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) Complete rewrite 02/17/21 (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. Added 11/17/2020
SHOpenWithDialog (Shell32) Invokes the "Open With" dialog in Windows Added 02/06/2021

Cross-Platform Libraries (Windows, Macintosh, and Linux)
pipecom $INCLUDE file that pipes console output to QB64. Win (using WinAPI), Mac, and Linux (using C libraries).Added 02/12/2021
encodeBase64, decodeBase64 (Crypt32, base64 (Linux and Mac)) Added 11/05/2020
mapvar, getmappedvalue (mappedvar) Header file that creates variables mapped to strings. Added 12/20/2020
(preproc) Header file that allows for usage of multiple preprocessor macros available to us in C++. Added 12/23/2020

Miscellaneous APIs / Libraries
hid_read, hid_write (hidapi) Provides HID access to devices over Bluetooth and USB connection (Windows) Test source for interfacing with Nintendo Switch Pro Controller over Bluetooth HID. Added 12/07/2020.

https://github.com/SpriggsySpriggs/Spriggsys-API-Collection

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.

Enjoy
« Last Edit: February 17, 2021, 11:55:40 pm by SpriggsySpriggs »
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
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 bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Spriggsy's API Collection
« Reply #2 on: August 18, 2020, 09:15:36 pm »
Walter, it's nice to hear from you again!

FellippeHeitor

  • Guest
Re: Spriggsy's API Collection
« Reply #3 on: August 18, 2020, 09:35:26 pm »
Daniel Dionne who goes online by [banned user], 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: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Spriggsy's API Collection
« Reply #4 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)
Shuwatch!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Spriggsy's API Collection
« Reply #5 on: August 18, 2020, 10:17:29 pm »
@[banned user] , I'd rather you promote this other language and server in "Off-Topic" so it doesn't muddle up this thread.
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Spriggsy's API Collection
« Reply #6 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: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Spriggsy's API Collection
« Reply #7 on: August 18, 2020, 10:53:28 pm »
Updated 08/18/20 with source code for Weather API using Geolocation from IP address.
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Spriggsy's API Collection
« Reply #8 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: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Spriggsy's API Collection
« Reply #9 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 »
Shuwatch!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Spriggsy's API Collection
« Reply #10 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 »
Shuwatch!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Spriggsy's API Collection
« Reply #11 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.
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Spriggsy's API Collection
« Reply #12 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 »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Spriggsy's API Collection
« Reply #13 on: August 19, 2020, 11:27:58 am »
@bplus I was wracking my brain last night trying to figure out where the issue was and immediately assumed it was because of UTC time which at the moment it was. Then when I tried it this morning and it still didn't work I compared the merged version with my original one and nothing was different. Ran both, no picture. Then I commented out the file deletion and looked at the response and saw that they were using a video link. I don't get why they would say Pic of the Day but use a video instead. They could have at least put some kind of picture in the response. Oh well. And I wasn't insulted or anything I was just trying to narrow down where the issue came from. I need to eventually hunt down who it was who wrote the Source Merger code because I can't remember who made it. I was going to make an InForm version of it and give credit to them for the original source. I need to search the forums.
« Last Edit: August 19, 2020, 11:37:15 am by SpriggsySpriggs »
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Spriggsy's API Collection
« Reply #14 on: August 19, 2020, 11:35:29 am »
Speaking of the bucket list there was a very old item about looking up words or subjects in dictionaries or encyclopedia's as a core part to some Sci Fi master AI App that could demonstrate the appearance of understanding of human text.

I guess IBM beat me to it with Watson but something in Basic beyond ELIZA of 50 years ago would be cool.