Skip to content

Instantly share code, notes, and snippets.

@BastelPichi
Created November 23, 2022 16:20
Show Gist options
  • Save BastelPichi/43e441f166fcd6a4c76f875dcbb91d5c to your computer and use it in GitHub Desktop.
Save BastelPichi/43e441f166fcd6a4c76f875dcbb91d5c to your computer and use it in GitHub Desktop.
Ebay Kleinanzeigen API docs
import requests
ACCESS_TOKEN = "YW5kcm9pZDpUYVI2MHBFdHRZ"
API_BASE = "https://api.kleinanzeigen.de/api"
header = {
"Authorization": f"Basic {ACCESS_TOKEN}",
"User-Agent": "okhttp/4.10.0",
}
# getting locations
params = {
"depth": 0,
#"q": "Darmstadt"
# if this param isn't passed, top citys will be returned
}
r = requests.get(f"{API_BASE}/locations/top-locations.json", headers=header, params=params)
print(r.json())
params = {
# possible: id,title,description,displayoptions,category.id,category.localized_name,ad-address.state,ad-address.zip-code,price,pictures,link,features-active,search-distance,negotiation-enabled,attributes,medias,medias.media,medias.media.title,medias.media.media-link,buy-now,store-id,store-title
"_in": "title,ad-address.state,ad-address.zip-code,price,pictures,link,start-date-time",
"q": "Fahhrad",
"page": 0, # if page is too high, line 45 will throw exception
"size": 41, # ads at the same time, 41 is max
"pictureRequired": "true", # only ads with pictures
"includeTopAds": "true", # include paid ads
"limitTotalResultCount": "false", # not sure about this
"locationId": 3331, # see above ^^
# optionally, the bike category can be used, however that (my understanding) only allows better filtering in the app:
#"categoryId": 217
}
r = requests.get(f"{API_BASE}/ads.json", headers=header, params=params)
data = r.json()
print(data)
for i in data["{http://www.ebayclassifiedsgroup.com/schema/ad/v1}ads"]["value"]["ad"]:
print(i["title"]["value"] + ":", i["ad-address"]["zip-code"]["value"], i["ad-address"]["state"]["value"])
print(i["link"][1]["href"])
print(i["pictures"]["picture"][0]["link"][4]["href"], "\n") # change 4 to smaller number for lower res pics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment