Get information on your favourite Marvel character

Log in to Vote
7
7 Votes • 12 Comments
Recently, Marvel has opened their API to the public. I imagine something like "marvel hulk" to get information on Hulk and a list of comics he is in.
I have started to code[1], but i have some trouble to get it working using two API keys (You need a public key and a hash, that is made of the md5'ed timestamp+public key+private key). Right now, Marvels API is restricted to 1000 views per day. I don't know, if DDG staff can change that.

[1]https://github.com/Gregsen/zeroclickinfo...
Source:
developer.marvel.com
• posted 4 years and 3 months ago • type: Spice (API calls) In Development

TV
List of characters should be done as well

eg https://duckduckgo.com/?q=the+simpsons+c...
posted by TV 4 years and 3 months ago Link
crazedpsyc
If I understand correctly, you need to create the second key for each query individually?
Try this:

Perl Code:
spice to => '...&hash=$2';

handle remainder => sub {
    ...
    my $privkey = md5_hex($timestamp.$ENV{DDG_SPICE_MARVEL_PRIVKEY});
    return $_, $privkey;
    ...
}


Make sense? The second value returned (separated by comma -- this is an array, just without parenthesis) is stuck in place of `$2` in the spice to URL, just like the first is stuck in `$1` for the query.
Another example of this is the AlternativeTo spice, which uses $1-$3 for different parts of the query.
posted by crazedpsyc 4 years and 3 months ago Link
gregsen
Yes and no. I am trying to start the duckpan server with two keys and I don't know how. The two keys and a timestamp are then used to calculate a hash. Is it even possible to start duckpan server with two keys?
I have tried
Code:
DDG_SPICE_MARVEL_PUBKEY=123,DDG_SPICE_MARVEL_PRIVKEY=456 duckpan server 
but it ends up as
Code:
...&apikey=123,DDG_SPICE_MARVEL_PRIVKEY=456&hash=...
instead.
posted by gregsen 4 years and 3 months ago Link
crazedpsyc
Ah, that's a shell issue. Try this:
Code:
DDG_SPICE_MARVEL_PUBKEY=123 DDG_SPICE_MARVEL_PRIVKEY=456 duckpan server
posted by crazedpsyc 4 years and 3 months ago Link
gregsen
Thank you, that works. I have tried to return more than one value in remainder, but that just substitute $1 with both values (seperated with / ).
I've read, that i need to use "spice from" but, well, regex. I have tried to copy and modify the regex from the docs (resp. AlternativeTo), but the local duckpan server just throws an exeception when I query it. This is what I tried (learning Regex is on my list, just not at the top ;) )
Code:
([^/]+)/?(?:([^/]+)/?)|)

Oh, and I don't understand, why ist {{ENV in the URL, but ${ENV in the remainder. Is there some doc, where I can learn about this? I guess it is something perl specific
posted by gregsen 4 years and 3 months ago Link
TV
Quote:
(learning Regex is on my list, just not at the top ;) )


Regexp cheat sheet
posted by TV 4 years and 3 months ago Link
zac
Any help we can give with this? Haven't seen a pull request for it but would be great to have :)
posted by zac Staff4 years and 1 month ago Link
gregsen
Hi, yes I am still on it, but my job has been quite heavy the last couple of weeks.
So far, everything seems to be working. I just need to write some tests and maybe think of another template. Right now i am using just some list to display the comics, but that looks a bit boring (and some comics have meaningfull titles such as 'Collection #1'...).
posted by gregsen 4 years and 1 month ago Link
crazedpsyc
Oh, not sure how I missed this, sorry!

Quote from gregsen:
I have tried to return more than one value in remainder, but that just substitute $1 with both values (seperated with / ).

Not sure how that would happen. Looking at the current code on github, it looks just about right.
The syntax error you have is `${ENV{...}}` on line 28. It should be $ENV{...}. %ENV is just a Perl hash which is auto-filled from the environment.
{{ENV{...}}} is not a Perl syntax at all, that is just a sort of rudimentary template language we use in spice. You won't find that anywhere else.
posted by crazedpsyc 4 years and 1 month ago Link
ScreapDK
Awesome idea! : D Wow! I can't wait for this to go live! : )
You see, I'm a huge comics/superhero-fan! : P
I'm so excited! ^_^
posted by ScreapDK Community Leader4 years and 3 months ago Link
ScreapDK
BTW, welcome to the forum @gregsen! : D
Always great to meet new people here. : )

And just a thing I was thinking about:
It seems like the use of the Marvel API is governed some Terms of Use.
The Terms can be found here:
Marvel API Terms of Use

Just in case DDG has some "legal staff" dealing with those kind of things. ; )
Again, nice to meet you! : )
posted by ScreapDK Community Leader4 years and 3 months ago Link
Jag
Make a pull request!
posted by Jag Staff3 years and 10 months ago Link