15

I would like to extract the data from MARVEL DEVELOPER by API code and analyze it (using R).

I got the following url from MARVEL website: http://gateway.marvel.com:80/v1/public/characters?apikey=f389fcb49ad574e10ca570867f4bfa43

I used httr package to collect the data:

install.packages("httr")
library(httr)
> url <- GET("http://gateway.marvel.com:80/v1/public/characters?orderBy=name&limit=100&apikey=f389fcb49ad574e10ca570867f4bfa43")
> content(url)
$code
[1] "MissingParameter"

$message
[1] "You must provide a hash."

I want to extract all this data to R. What should I do/read?

Thanks.

Tal Galili
  • 24,605
  • 44
  • 129
  • 187
Tal Reznik
  • 151
  • 1
  • 1
  • 3
  • 3
    Did you get a hash when you signed up? Obviously you should pass it on to your request http://developer.marvel.com/documentation/generalinfo – lukeA Feb 26 '15 at 13:21

3 Answers3

15

You have to provide ts (timestamp) and hash parameter. Hash is (according to documentation) = md5(ts+privateKey+publicKey)

You can compute md5 with:

library(digest)
hash <- digest(paste0(ts, privateKey, publicKey), algo="md5")

Server-side applications must pass two parameters in addition to the apikey parameter:

ts - a timestamp (or other long string which can change on a request-by-request basis)

hash - a md5 digest of the ts parameter, your private key and your public

key (e.g. md5(ts+privateKey+publicKey) For example, a user with a public key of "1234" and a private key of "abcd" could construct a valid call as follows:

http://gateway.marvel.com/v1/public/comics?ts=1&apikey=1234&hash=ffd275c5130566a2916217b101f26150 (the hash value is the md5 digest of 1abcd1234)

heLL0
  • 1,357
  • 3
  • 23
  • 30
bergant
  • 7,122
  • 1
  • 20
  • 24
6

You need to have the following combination ts+ your private key+ your public key

Please check the below example from MARVEL:

For example, a user with a public key of "1234" and a private key of "abcd" could construct a valid call as follows: http://gateway.marvel.com/v1/public/comics?ts=1&apikey=1234&hash=ffd275c5130566a2916217b101f26150 (the hash value is the md5 digest of 1abcd1234)

ts -1 private key- abcd public key - 1234

Tom Okila
  • 61
  • 1
  • 1
4

The hash described in other answers is only when you're using your private key.

The public key can be used in the way you're attempting by adding a referrer:

curl --referer localhost http://gateway.marvel.com:80/v1/public/characters?apikey=f389fcb49ad574e10ca570867f4bfa43

I don't know R so a curl request will have to do.

In your developer account you can list the allowed referrers. I have localhost but your's can be whatever...

Adrian Lynch
  • 8,237
  • 2
  • 32
  • 40