This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Marvel API

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Marvel API

Post by spithash »

Hello there!

Some friends requested a script that could fetch info from http://developer.marvel.com/docs and I thought I should give it a try and see if someone's offering to help me around.

To get info from that API you need an account and an API key (which both are easy to get on their website, took me 2 minutes to get everything straight)

So... after I generated the API key I was able to search for "Spider-Man" for example and got a bunch of information from the first section "
/v1/public/characters" such as:

Code: Select all

        "id": 1009610,
        "name": "Spider-Man",
        "description": "Bitten by a radioactive spider, high school student Peter Parker gained the speed, strength and powers of a spider. Adopting the name Spider-Man, Peter hoped to start a career using his new abilities. Taught that with great power comes great responsibility, Spidey has vowed to use his powers to help people.",
        "modified": "2013-10-24T13:52:13-0400",
        "thumbnail": {
          "path": "http://i.annihil.us/u/prod/marvel/i/mg/3/50/526548a343e4b",

So I was hoping if someone could help me scrap all that information and post it in the channel for example by character searching !marvel Spider-Man

I sure hope I explained everything needed :P
Thanks.
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The results you are looking at are in JSON format. Here's an example of such a request.

Code: Select all

package require http
package require json

set query [::http::formatQuery name $name key 123456789]
set http  [::http::geturl https://site.com/api/ -query $query]
set json  [::http::data $http]
set data  [::json::json2dict json]
and then use dict to get stuff you want from $data variable.
Once the game is over, the king and the pawn go back in the same box.
Post Reply