Hi there
i have reset my credentials as suggested in similar question previously, however i am
still receiving the same error 'groups'.....
def getNearbyVenues(names, latitudes, longitudes):
radius=500
LIMIT=100
venues_list=[]
for name, lat, lng in zip(names, latitudes, longitudes):
print(name)
url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v=
{}&ll={},{}&radius={}&limit={}'.format(
CLIENT_ID,
CLIENT_SECRET,
VERSION,
lat,
lng,
radius,
LIMIT)
results = requests.get(url).json()["response"]['groups'][0]['items']
venues_list.append([(
name,
lat,
lng,
v['venue']['name'],
v['venue']['location']['lat'],
v['venue']['location']['lng'],
v['venue']['categories'][0]['name']) for v in results])
nearby_venues = pd.DataFrame([item for venue_list in venues_list for item in venue_list])
nearby_venues.columns = ['Neighborhood',
'Neighborhood Latitude',
'Neighborhood Longitude',
'Venue',
'Venue Latitude',
'Venue Longitude',
'Venue Category']
return(nearby_venues)
illembe_venues = getNearbyVenues(names=df_illembe['Neighborhood'],
latitudes=df_illembe['Latitude'],
longitudes=df_illembe['Longitude']
)
i have also written the code in a new notebook and receiving the same error
Related
When I used the MODIS data,I got a problem about the Type.
I got the coord by xarray(python 3.9),but I couldn't get the same type as 'GEO2D'.
xr_tmp = xr.Dataset(
{
'Gpp_500m' : (('XDim', 'YDim','time'), Gpp_500m),
'Npp_500m' : (('XDim', 'YDim','time'), Npp_500m),
'Npp_QC_500m' : (('XDim', 'YDim','time'), Npp_QC_500m),
},
coords=dict(
lon = (['XDim', 'YDim'],lon),
lat = (['XDim', 'YDim'],lat),
time = _time_
# 'latitude': lat,
# 'longitude': lon,
# 'time': _time_,
)
)
The figures are shown bellow,Could U help me? (use xarray or pyModis if necessary)
You can see the difference from the pictures as follow.
I did a Scopus search using rscopus package with the following code:
author_search(au_id = "Smith",
searcher = "affil(princeton) and authlast")
I got the following error:
Error in get_results(au_id, start = init_start, count = count, facets = facets, :
Unauthorized (HTTP 401).
However, this code works well:
scopus_search(query = "Vocabulary", max_count = 20,
count = 10)
I have set the Scopus API Key using options("elsevier_api_key" = "MY-API-KEY-HERE"). So, I wonder what the problem is.
how can i fetch the latitude, longitude from url 1 - http://api.linear.com/api/iplookup.json
and
pass in url 2 - https://linear.openstreetmap.org/reverse?lat=28.6331&lon=77.2207&format=json
using python request module with get and post method
import requests
data=requests.get("http://api.letgo.com/api/iplookup.json")
k=data.text
bad= ['{','}','"']
for i in bad:
k= k.replace(i, '')
#printing string without few signs
l=k.split(",")
for j in l:
print(j)
this is how i change before
import requests
url='https://nominatim.openstreetmap.org/reverse'
obj={'lat':'28.6331','lon':'77.2207','format':'json'}
op=requests.post(url,params=obj)
op.url
You can get the data directly without converting the response to data.text first:
import requests
url = 'https://api.letgo.com/api/iplookup.json'
data = requests.get(url).json()
lat = data['latitude']
lon = data['longitude']
url2 = 'https://nominatim.openstreetmap.org/reverse'
params = {'lat': lat, 'lon': lon, 'format': 'json'}
req = requests.post(url2, params=params)
print(req.text)
I'm trying to use the httr R package to place orders on BitMex through their API.
I found some guidance over here, and after specifying both my API key and secret in respectively the objects K and S, I've tried the following
verb <- 'POST'
expires <- floor(as.numeric(Sys.time() + 10000))
path <- '/api/v1/order'
data <- '{"symbol":"XBTUSD","price":4500,"orderQty":10}'
body <- paste0(verb, path, expires, data)
signature <- hmac(S, body, algo = 'sha256')
body_l <- list(verb = verb, expires = expires, path = path, data = data)
And then both:
msg <- POST('https://www.bitmex.com/api/v1/order', encode = 'json', body = body_l, add_headers('api-key' = K, 'api-signature' = signature, 'api-expires' = expires))
and:
msg <- POST('https://www.bitmex.com/api/v1/order', body = body, add_headers('api-key' = K, 'api-signature' = signature, 'api-expires' = expires))
Give me the same error message when checked:
rawToChar(msg$content)
[1] "{\"error\":{\"message\":\"Signature not valid.\",\"name\":\"HTTPError\"}}"
I've tried to set it up according to how BitMex explains to use their API, but I appear to be missing something. They list out a couple of issues that might underly my invalid signature issue, but they don't seem to help me out. When following their example I get the exact same hashes, so that seems to be in order.
bit late to the party here but hopefully this helps!
Your POST call just needs some minor changes:
add content_type_json()
include .headers = c('the headers') in add_headers(). See example below:
library(httr)
library(digest)
S <- "your api secret"
K <- "your api key"
verb <- 'POST'
expires <- floor(as.numeric(Sys.time() + 10))
path <- '/api/v1/order'
data <- '{"symbol":"XBTUSD","price":4500,"orderQty":10}'
body <- paste0(verb, path, expires, data)
signature <- hmac(S, body, algo = 'sha256')
msg <- POST('https://www.bitmex.com/api/v1/order',
encode = 'json',
body = data,
content_type_json(),
add_headers(.headers = c('api-key' = K,
'api-signature' = signature,
'api-expires' = expires)))
content(msg, "text")
I have a package on CRAN - bitmexr - that provides a wrapper around the majority of BitMEX's API endpoints that you might be interested in. Still quite a "young" package so I would welcome any feedback!
I'm currently trying to loop through a searchTwitter() call for each of 21 players in the NBA to get the 100 most recent tweets about them. However, weirdly, the call was working within my for loop of lastMVPs (which is a list of the names), but then stopped after 10 loops through, which would have only been 1,000 API calls. Now the call only works when outside of the for loop. Does anyone have any idea why this is?
For example - this works:
searchTwitter("Lebron James", n = 2, lang = 'en')
But this does not:
for (name in lastMVPs) {
newitem = searchTwitter(name, n = 100, lang = 'en')
df = twListToDF(newitem)
name = df$text
tweetMatrix = cbind(tweetMatrix, name)
}
And I get the error
Error in twListToDF(newitem) : Empty list passed to twListToDF
In addition: Warning message:
In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit, :
100 tweets were requested but the API can only return 0
Which doesn't make sense to me because how can the API be maxed out when it's already working for my call outside of the loop?