Google API doesn't return data for ISBN - api

I am using the Google API to search for books by ISBN.
I am trying with these 3 codes
0716604892, 0716604892, 0544506723
like this
https://www.googleapis.com/books/v1/volumes?q=isbn:0716604892
https://www.googleapis.com/books/v1/volumes?q=isbn:0716604892
https://www.googleapis.com/books/v1/volumes?q=isbn:0544506723
but the last one doesn't return anything when the book exists, and the ISBN code is right.
Why is that?

Use ISBN in uppercase.
type it as:
https://www.googleapis.com/books/v1/volumes?q=ISBN:0544506723
instead of:
https://www.googleapis.com/books/v1/volumes?q=isbn:0544506723

Related

Is there an easy way to filter result by combining both like %% and in together using OR? I could not find a way

select authorname
from library
where author like '%ROSARIO RAMIREZ CORTE%'
or author like '%Ann Rice%'
Since the Excel sheet I have doesn't provide the exact match of author name, that's why I want to use like and I was able to find the 'missing' record. But I have like 300 authors in my list, anyway to combine the and and in together? Instead keep doing and author like forever?
For example here is my sample result, it is correct but I have to keep adding author like in each new line:
AuthorName
ROSARIO RAMIREZ CORTEZ
Anne Rice
You can use the IN operator as a shorthand for multiple OR's I'm pretty sure.
SELECT authorName FROM library WHERE authorName IN ('%Ann Rice%', ...)

Best way to query postgres db from django to list all users (tab1) which have active book borrows (tab2)?

I have a simple application in Django. The simple logic is kind of book library.
Tab1. stores the users:
class Readers(Model):
last_name = CharField(...)
first_name = CharField(...)
Tab2. stores the book borrows:
class BookBorrows(Model):
index = IntegerField(db_index=True, ...)
reader = ForeignKey('Reader', ...)
book = ForeignKey('Book', ...)
active = BooleanField(...)
I am struggling to figure out what is the proper solution to get:
List of all Readers with at least one borrowed book (the field active==True).
List of all Readers without any currently borrowed book (the field active==False).
After some serche I am thinking about django .raw('QUERY ...') or maybe is there a more django-friendly way to achieve this?
P.S.:this is my first question posted to SO.
reader_ids_with_book = BookBorrows.objects.filter(active=True).values_list(
'reader_id', flat=True
)
readers_without_book = Readers.objects.exclude(id__in=list(reader_ids_with_book))
first query gives you the valuelist queryset of users who borrowed at least one book and you can use this in order to find out other users who didnot borrow anything yet

VK API - return city names in latin

I am using VK API to get list of cities in specific country. Does anyone know how to show Russian cities (which are in Cyrilic) in Latin?
Example of JSON response:
http://api.vk.com/method/places.getCities?lang=en&country_id=1&count=1000&need_all=1
I am trying to check if city exists, but if someone enter city name in latin, in some cases city check works, for example Vladivostok is Владивосток, but Moscow is Москва.
I found one solution that works for me: firstly get all cities ids by places.getCities (database.getCities) method and then use database.getCitiesById providing saved cities ids like following:
database.getCitiesById?lang=en&city_ids=1,2,123
In request to this API method you can specify needed language by parameter "lang" (e.g. lang=en) and up to 1k comma-separated cities ids (e.g. city_ids=1,2,123,...).
database.getCitiesById official documentation
As an alternative, you can get the static list of Russian cities here. This JSON array contains the slug name of each city in English. It's a free list, so anyone can edit and add correct information for any localities.

How can I search for albums with generic titles using the Spotify Web API?

It is possible to search by name for an album in the Spotify catalog using the Spotify Web API.
However, if the album name is a common word or phrase, the search response may contain thousands of results. I can't see a way to narrow the search by artist name.
Here is an example: searching for album Country by artist Giant Panda Guerilla Dub Squad.
The API request is:
http://ws.spotify.com/search/1/album?q=country
The response is:
<?xml version="1.0" encoding="UTF-8"?>
<albums xmlns="http://www.spotify.com/ns/music/1" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<opensearch:Query role="request" startPage="1" searchTerms="country" />
<opensearch:totalResults>11861</opensearch:totalResults>
<opensearch:startIndex>0</opensearch:startIndex>
<opensearch:itemsPerPage>100</opensearch:itemsPerPage>
<album href="spotify:album:1Wcnyz2zYWLIPZ1K63RXdW">
<name>How Country Feels</name>
<artist href="spotify:artist:56x8mYvS3cyDGAi8N2FxbB">
<name>Randy Houser</name>
</artist>
<id type="upc">886443789852</id>
<popularity>0.73964</popularity>
<availability>
<territories>CA US</territories>
</availability>
</album>
...more albums...
</albums>
There are 11861 results, and the results are paged, with 100 albums per page. A request can be made to get the next page, but if the album I'm looking for is on the last page I will have to make 118 separate requests to the API before I find it.
Is there a better way?
You can use the advanced search query language to help, especially if you know the artist in advance. For example:
http://ws.spotify.com/search/1/album?q=artist:Giant Panda Guerilla Dub Squad
...will limit the search to albums by that artist.
http://ws.spotify.com/search/1/album?q=artist:Giant Panda Guerilla Dub Squad Country
...will return only the album you want.
The full advanced search reference is currently unavailable in the chaos that was the new Spotify redesign, but you can find it in the Wayback machine here.

Can Redis do prefix matching?

Lets say I have a set of cities in the world like so:
EUKLOND
EUKMANC
EUKEDIN
EITROME
EITMILA
EITNAPE
EFRPARI
EFRAVIG
EFRBRES
Where the first letter is continent, next two are country and the trailing 4 are an abbreviated city name.
I would like to be able to search this set by passing in "E" which would return all the entries or EIT and retrieve all the entries for Italy or EFRPARI and get just the Paris entry.
Is this something I can do with Redis?
Generally, it's an Auto-Complete scenario.
Salvatore Sanfilippo (#Antirez), Redis's author, wrote a thorough blog post about how to accomplish this.
UPDATE: I just saw another great blog post, that first takes Salvatore's solution and explains it in a clear way, and second offers another solution that is good also for multiple-word phrases.