Amadeus API Hotel description - api

Is there a way to get a more detailed hotel description?
For example, by using this endpoint https://test.api.amadeus.com/v1/reference-data/locations/hotels/by-hotels?hotelIds=ACPAR419 I'm getting such a response
{
"data": [
{
"chainCode": "AC",
"iataCode": "PAR",
"dupeId": 700140792,
"name": "LE NOTRE DAME",
"hotelId": "ACPAR419",
"geoCode": {
"latitude": 48.85306,
"longitude": 2.34654
},
"address": {
"countryCode": "FR"
}
}
],
"meta": {
"count": 1,
"links": {
"self": "https://test.api.amadeus.com/v1/reference-data/locations/hotels/by-hotels?hotelIds=ACPAR419"
}
}
}
What I exactly need: After getting a hotel list from the search, allow the user to open the Hotel details page of one of the found hotels and get more detailed information (Long description, images, rooms, amenities, reviews,). But the above-mentioned endpoint does not provide such a piece of information, only "Hotel name" and a few other fields. Should I combine more than one endpoint or there is already such a service and I just can't see it?

Hotel Booking flow with Amadeus Self-service APIs is with 3 steps :
Step 1: Find all available hotels in a given city or location using
Hotel List API
Step 2: Find the available prices with room details, descriptions and more using Hotel Search API
Step 3: Complete the booking engine using Hotel Booking API
https://developers.amadeus.com/blog/build-hotel-booking-engine-amadeus-api
with the updated version of Hotel Search V3.0, unfortunately, the information on hotel image/address/contact details/rating/amenities is missing.
https://amadeus4dev.github.io/developer-guides/migration-guides/hotel-search/#search-hotels-by-a-city-or-geocode

Related

Does Google Scholar have an API available that we can use in our research applications?

I am working on a research publication and collaboration project that has a literature search feature in it.
Google Scholar seems like it will work since it is an open source tool but, when I researched Google Scholar, I could not find any information about it having an API.
Please let me know if there is any API for Google Scholar that is valid.
TIA.
There's no official Google Scholar API. There are third-party solutions like free scholarly Python package which supports profile, author, cite and organic results (search_pubs seems to be the method to get organic results, although method name confuses me).
Note that by using scholarly constantly without a requests rate limit, Google may block your IP (mentioned by #RadioControlled). Use it wisely.
Alternatively, there's a Google Scholar API from SerpApi which is a paid API with a free plan that supports organic, cite, profile, author results and bypasses all the blocks on SerpApi backend so it won't block your IP.
Example code to parse profile results using scholarly using search_by_keyword method:
import json
from scholarly import scholarly
# will paginate to the next page by default
authors = scholarly.search_keyword("biology")
for author in authors:
print(json.dumps(author, indent=2))
# part of the output:
'''
{
"container_type": "Author",
"filled": [],
"source": "SEARCH_AUTHOR_SNIPPETS",
"scholar_id": "LXVfPc8AAAAJ",
"url_picture": "https://scholar.google.com/citations?view_op=medium_photo&user=LXVfPc8AAAAJ",
"name": "Eric Lander",
"affiliation": "Broad Institute",
"email_domain": "",
"interests": [
"Biology",
"Genomics",
"Genetics",
"Bioinformatics",
"Mathematics"
],
"citedby": 552013
}
... other author results
'''
Example code to parse organic results using Google Scholar Profile Results API from SerpApi:
import json
from serpapi import GoogleScholarSearch
# search parameters
params = {
"api_key": "Your SerpApi API key",
"engine": "google_scholar_profiles",
"hl": "en", # language
"mauthors": "biology" # search query
}
search = GoogleScholarSearch(params)
results = search.get_dict()
# only first page results
for result in results["profiles"]:
print(json.dumps(result, indent=2))
# part of the output:
'''
{
"name": "Masatoshi Nei",
"link": "https://scholar.google.com/citations?hl=en&user=VxOmZDgAAAAJ",
"serpapi_link": "https://serpapi.com/search.json?author_id=VxOmZDgAAAAJ&engine=google_scholar_author&hl=en",
"author_id": "VxOmZDgAAAAJ",
"affiliations": "Laura Carnell Professor of Biology, Temple University",
"email": "Verified email at temple.edu",
"cited_by": 384074,
"interests": [
{
"title": "Evolution",
"serpapi_link": "https://serpapi.com/search.json?engine=google_scholar_profiles&hl=en&mauthors=label%3Aevolution",
"link": "https://scholar.google.com/citations?hl=en&view_op=search_authors&mauthors=label:evolution"
},
{
"title": "Evolutionary biology",
"serpapi_link": "https://serpapi.com/search.json?engine=google_scholar_profiles&hl=en&mauthors=label%3Aevolutionary_biology",
"link": "https://scholar.google.com/citations?hl=en&view_op=search_authors&mauthors=label:evolutionary_biology"
},
{
"title": "Molecular evolution",
"serpapi_link": "https://serpapi.com/search.json?engine=google_scholar_profiles&hl=en&mauthors=label%3Amolecular_evolution",
"link": "https://scholar.google.com/citations?hl=en&view_op=search_authors&mauthors=label:molecular_evolution"
},
{
"title": "Population genetics",
"serpapi_link": "https://serpapi.com/search.json?engine=google_scholar_profiles&hl=en&mauthors=label%3Apopulation_genetics",
"link": "https://scholar.google.com/citations?hl=en&view_op=search_authors&mauthors=label:population_genetics"
},
{
"title": "Phylogenetics",
"serpapi_link": "https://serpapi.com/search.json?engine=google_scholar_profiles&hl=en&mauthors=label%3Aphylogenetics",
"link": "https://scholar.google.com/citations?hl=en&view_op=search_authors&mauthors=label:phylogenetics"
}
],
"thumbnail": "https://scholar.googleusercontent.com/citations?view_op=small_photo&user=VxOmZDgAAAAJ&citpid=3"
}
... other results
'''
There is a dedicated Scrape historic Google Scholar results using Python blog post of mine at SerpApi which shows how to scrape historic 2017-2021 Organic, Cite Google Scholar results to CSV, SQLite.
Disclaimer, I work for SeprApi
A quick search shows that others are trying to implement such APIs, but Google does not provide one. It is not clear whether this is legal, see for instance
How to get permission from Google to use Google Scholar Data, if needed?.

How to replace session with stateless rest apis?

So, I am trying to make a shopping cart web architecture on rest framework where I am struggling to use browser storages to use as an alternative to maintaining the state.
I tried the window.localStorage and window.sessionStorage() APIs but it failed in the case of the private browsing mode in Safari and Opera.
So can anyone help out in the figuring other methods by which I can maintain states in rest based architecture?
You don't need sessions to store application state. User resources.
On approach would be to model every shopping cart as a resource with a unique ID:
/shop/shoppingcarts/E73AC56C-BDF7-11E5-81F1-8E2EDB915C80
The client application in the browser would read this resource:
GET /shop/shoppingcarts/E73AC56C-BDF7-11E5-81F1-8E2EDB915C80
It would add an item to the cart:
POST /shop/shoppingcarts/E73AC56C-BDF7-11E5-81F1-8E2EDB915C80/items
{
"itemId": "1234",
"quantity": 1
}
It would list the contents of the shopping cart:
GET /shop/shoppingcarts/E73AC56C-BDF7-11E5-81F1-8E2EDB915C80/items
[
{
"itemId": "1234",
"title": "Some nice item",
"quantity": 1,
"price", 12.34,
"priceTotal": 12.34
},
{
"itemId": "9876",
"title": "Some other nice item",
"quantity": 2,
"price", 0.99,
"priceTotal": 1.98
}
]
The web application would remove an item from the cart:
DELETE /shop/shoppingcarts/E73AC56C-BDF7-11E5-81F1-8E2EDB915C80/items/9876
I think you get the idea.

REST pattern create, update and delete same endpoint

I have a page where I list the books of a school. The user can update a book, add a new book or delete an existing book. All actions must be saved when the form is submitted.
How can i map a rest API for that? I could take advantage of the endpoints i already have.
UPDATE
PUT /schools/1/books
{
"books": [
{
"id": "1",
"name": "Book 1"
}
]
}
CREATE
POST /schools/1/books
{
"books": [
{
"name": "Book 2"
},
{
"name": "Book 3"
}
]
}
DELETE
DELETE /schools/1/books
{
"books": [
{
"id": 2
}
]
}
But I need everything to run on the same transaction, and wouldn't make sense to submit 3 requests.
I also thought of creating a new endpoint where I would create books that doesn't exists, update books that exists, and remove books that are not present on the request.
So if this school has Book 1 and Book 2, I could update Book 1, create New Book and remove Book 2 with:
PUT /schools/1/batch-books
{
"books": [
{
"id": "1",
"name": "Updated Book 1"
},
{
"name": "New Book"
}
]
}
Do you guys have other options?
I would separate things into different resources:
/books and /books/{id} for books. They gives book details and allow to manage them.
/schools and /schools/{id} for schools. They gives school details and allow to manage them.
/schools/{id}/books to associate books in schools. I mean books that are available within a school. This resource provides methods to manage a list of links to books.
Let me detail the last resource. In fact, this is related to hypermedia. In the following, I'll use JSON-LD but you're free to use other hypermedia tools.
A GET method will return the list of associated books:
GET /schools/1/books
[
{
"#id": "http://api.example.com/books/1895638109"
},
{
"#id": "http://api.example.com/books/8371023509"
}
]
You can notice that you can implement mechanisms to allow to get more details if needed. Leveraging the Prefer header seems to be a great approach (see the link below for more details).
In addition, you could provide the following methods:
POST to add a link to the school. The request payload would be: {"#id": "http://api.example.com/books/1895638109"}. The response should be a 201 status code.
DELETE to delete a specific link from a school. A query parameter could be used to specify which link to remove.
PATCH to allow to do several operations in one call and actually provide some batch processing. You can leverage at this level JSON-PATCH for the request processing. Within the response, you could describe what happens. There is no specification at this level so you're free to use what you want... Here is a sample for the request payload:
PATCH /schools/1/books/
[
{
"op": "add", "value": "http://api.example.com/books/1895638109"
},
{
"op": "remove", "path": "http://api.example.com/books/8371023509"
}
]
Reading the following links could give you some hints on the way to design such use case:
Implementing bulk updates within RESTful services: http://restlet.com/blog/2015/05/18/implementing-bulk-updates-within-restful-services/
On choosing a hypermedia type: http://sookocheff.com/post/api/on-choosing-a-hypermedia-format/
Creating Client-Optimized Resource Representations in APIs: http://www.freshblurbs.com/blog/2015/06/25/api-representations-prefer.html
Hope it helps you,
Thierry

RESTful design: resolving relationships

My questions are based on this article: should-restful-apis-include-relationships
Let's say I have the following resources: users and roles
A single user can be retrieved by api/users/{userId} and a single role by api/roles/{roleId}
The response data of a single user looks like this:
Id: 1
Firstname: Alice
Lastname: Henderson
Email: alice#henderson.com
Roles: api/users/1/roles
To get the roles of this user the application needs to call the returned url api/users/1/roles
For displaying 1 user this approach seems to be ok. But if I want to display all users with their corresponding roles the application needs 1 call to api/users and x calls to api/users/x/roles
How can this design be improved for retrieving multiple users and resolving their role relationships?
You can design your API to accept one or more query parameters which specify the detail level you desire. For instance:
GET /api/users/1?expand=role(self, id, name)
{
"id": 1
"firstName": "Alice"
"lastName": "Henderson"
"email": "alice#henderson.com"
"roles": [
{
"self": "api/roles/4"
"id": 4
"name": "Administrator"
},
{
"self": "api/roles/7"
"id": 7
"name": "Uberuser"
}
]
}

REST: Link resources with dependency

I'm trying to design a relationship between two different resources with dependency. The scenario is:
Two resources, the first one called "account" and the second one called "person".
In my API the "person" resource is a representation of a person in real world, with name, age, gender, address, telephone, etc. Account is the resource responsible to authenticate a person, like a login.
So the representation of "person" resource looks like below:
{
"id": "7828292",
"name": "Joseph Climber",
"email": "yourmail#email.com",
"gender": "M",
"telephones": {
"main": {
"number": "898987777"
},
"secondary": {
"number": "909099090"
},
"business": {
"number": "937363902"
}
},
"address": {
         "rel": "address",
         "href": "person/{ID}/address"
     }
}
And the representation of "account" resource looks like:
{
"id": "login#email.com",
"tokenAccess": "5E69FAE25F4B4F3E8CC5DE09A8163520",
"link": {
"rel": "person",
"href": "person/{id}"
}
}
My problem is: when I create a new person (POST person) I don't have a way to authenticate the new person, in this case is necessary to create a new account to do this, so this seems a little bit confusing for the API consumers, because the API doesn't express this kind of relationship naturally (basic concept of a good API design).
What is the best way to represent this dependency between account and person resource?
Maybe if someone attempts to POST to /person without an access token, then return a status code 401 Unauthorized with a body something like:
{
"#type": "error",
"description": "You must be authenticated to POST to person. If you do not have an account, then POST to /account to get an access token."
}
I imagine that would be intuitive enough for developers using the API.