How can i send minimum requests to Gravitee? - api

I need to send 2 request via Gravitee: 1 for get Token from an API and then i can read/write/update with the API. How can i do it with the minimum request to Gravitee?

Related

Amadeus test.api.amadeus.com/v2/shopping/hotel-offers and other api V2 hotel api return a 401 invalid access token

I'm working on a hotel booking application, and trying to integrate amadeus api. I'm using the test api base url https://test.api.amadeus.com
when sending a request for flight-offers i get the response and the token is valid.
But when i'm trying to use the hotel-offers end point with the same token(before it expires in 30 mins) it returns a 401 message.
https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=LON&destinationLocationCode=NYC&departureDate=2022-01-16&adults=1&travelClass=ECONOMY works
flight offers endpoint
https://test.api.amadeus.com/v2/shopping/hotel-offers?cityCode=LON&checkInDate=2022-01-05&checkOutDate=2022-01-07 does not work
hotel offers endpoint
i know that a token expires after 30 min and took that into consideration.
Is there a problem with this endpoint:
https://test.api.amadeus.com/v2/shopping/hotel-offers

Distributing API calls to users for web app

We are trying to call one of Google's APIs and analyze the data and then display it for the user on our site. We realize we can make calls to the API through our server using php or python, but because of Google's limit, we are looking for an option that will have the API call come from the user, instead of our server. Is there a way for a web app to distribute the requests amongst the users instead of make all the calls from our server?
Thank you very much as this has been a tricky one to Google.
I highly doubt that this is possible. The API request is per API key and you can't provide every user with their own API key.
If the scenario you are trying to achieve requests possibly the same data for multiple users. I highly suggest you save/cache the API request. This will minimize the times your server send API request to google since you saved that request to your server. You can then set an expiration for your saved/cached API request to renew X days.
Scenario
user 1: request data for item 123 from API.
server: sends request to API server, and save
user 2: request data for item 123
server: return saved API response

Twitter API call limit - per token or per IP?

I am developing a feature that display the recent 5 tweets for a particular tweeter user. I am using the application-only authentication and get the bearer token to query the tweeter API.
I saw there is a limit on the numbers of request to Twitter API in every 15 mins.
https://dev.twitter.com/rest/public/rate-limits
user auth app auth
GET statuses/user_timeline statuses 180 300
My question is the limit is per bearer token or per IP?
For example, If
User A and user B are using the same token, query the same user's timeline(Eg, Yahoo), would the limit will be 300/2 for each user in every 15 mins?
User A and user B are using the same token, query the different user's timeline(Eg, One for Google, One for Yahoo), would the limit will be 300/2 for each user in every 15 mins?
Yes, it will be divided by 2. It is recommended to use User authentication to user credentials for such case.
The rate limits are on the endpoint. So if you do 5 requests that start with statuses/user_timeline statuses only 295 request will remain.
I am not sure if you know c# but you can check this quite easily with the Twitter library Tweetinvi as followed:
var remainingBefore = RateLimit.GetCurrentCredentialsRateLimits().StatusesUserTimelineLimit.Remaining;
var tweets = Timeline.GetUserTimeline(userId);
var remainingAfter = RateLimit.GetCurrentCredentialsRateLimits().StatusesUserTimelineLimit.Remaining;

YouTube API. Check for user was subscribed

What the best way to determine when authorized user was subscribed to YouTube channel by channel's id through YouTube Data API? I assuming it is possible somehow by "Subscriptions.list" API method. But how exactly?
If you know the channelId of the channel you want to check the user is subscribed to, you can perform an HTTP GET request on the subscriptions/list endpoint with the parameters part set to id and mine set to true:
HTTP GET https://www.googleapis.com/youtube/v3/subscriptions?part=id&mine=true&key={YOUR_API_KEY}
You could also pass in snippet for part to get information about each channel the user is subscribed to. With this approach, you would have to iterate through every channel that authenticated user is subscribed to, and check if your channel exists in that list.
You could also send an authenticated POST request to the subscriptions/insert endpoint with the channelId of the channel you want to subscribe to with the part param snippet, and if the user is already subscribed to that channel, the request will return a 400 error with the message subscriptionDuplicate.
HTTP POST https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&key={YOUR_API_KEY}

Why I get a 400 bad request with an auth request to Twitter?

This is the resource I calling for:
https://api.twitter.com/1.1/statuses/user_timeline.json&count%3D2%26oauth_consumer_key%3DVnNeRUCEZAEQFgSR6j7RA%26oauth_nonce%3D47ce3f3bc553afa24qwwWsa6d651d697407d279%26oauth_signature_method%3DHAS12MAC-SHA1%26oauth_timestamp%3D13739599ASdas95%26oauth_token%3D1041as30304-HEYQ1S65ybBYP2J1Xey1sK7xql1nyU2ykZDr9txA%26oauth_version%3D1.0%26screen_name%3DMyAgency
but I get an empty page with NetworkError: 400 Bad Request.
Where am I wrong? And where do I check this?
This status code will be returned during version 1.0 rate limiting. In API v1.1, a request without authentication is considered invalid and you will get this response.
If you're using version 1.0 - The Twitter API only allows clients to make a limited number of calls in a given hour. This policy affects the APIs in different ways.