Topic: API GET request returns "url": null

Posted under e621 Tools and Applications

Hello!
I have a problem. API GET request returns "url": null if I use User-Agent on some posts.
For example here: https://e621.net/posts.json?tags=id:3862274
If I try to open a link through a browser, the "url" is available to me. If I do this from my application or via the online API with User-Agent I get "url": null
This is strange, could you help me solve this problem?

The URLs for images tagged with young -rating:s images don't appear in the API by default. You either need to use authentication or create the URL yourself from the MD5 hash.

See e621:api#api - specifically the "Logging In" section.

Pup

Privileged

furkamore said:
Hello!
I have a problem. API GET request returns "url": null if I use User-Agent on some posts.
For example here: https://e621.net/posts.json?tags=id:3862274
If I try to open a link through a browser, the "url" is available to me. If I do this from my application or via the online API with User-Agent I get "url": null
This is strange, could you help me solve this problem?

Posts caught by the default blacklist don't give a url unless you authenticate with an API key, and that post's tagged with young so you can't see the image without logging in.

To get an API key click on "Account" on the top bar then "Manage API Access."

Then in your code you need to use HTTP Basic Auth, whatever language/library you're using likely has a way to do it. If you're using Python you can do:

import requests
from requests.auth import HTTPBasicAuth

session = requests.Session()
session.auth = HTTPBasicAuth("E6 username", "E6 API key")
session.headers = {"User-Agent": "Program_Name/1.0 (by Username on E621)"}

response = session.get(URL)
json = response.json()

faucet said:
The URLs for images tagged with young -rating:s images don't appear in the API by default. You either need to use authentication or create the URL yourself from the MD5 hash.

See e621:api#api - specifically the "Logging In" section.

pup said:
Posts caught by the default blacklist don't give a url unless you authenticate with an API key, and that post's tagged with young so you can't see the image without logging in.

To get an API key click on "Account" on the top bar then "Manage API Access."

Then in your code you need to use HTTP Basic Auth, whatever language/library you're using likely has a way to do it. If you're using Python you can do:

import requests
from requests.auth import HTTPBasicAuth

session = requests.Session()
session.auth = HTTPBasicAuth("E6 username", "E6 API key")
session.headers = {"User-Agent": "Program_Name/1.0 (by Username on E621)"}

response = session.get(URL)
json = response.json()

Thanks to both of you!
I thought about it because almost all the content was related to cub content, but it was not in the documentation.
If this limits the standard tags from the block list, then for my case it would be better to use the API without authorization :)

  • 1