Goodreads Developers discussion

48 views
questions > How do I get Good Reads Book ID from a Good Reads URL?

Comments Showing 1-4 of 4 (4 new)    post a comment »
dateUp arrow    newest »

message 1: by v (last edited May 26, 2015 07:31AM) (new)

v (avins) EDIT: Can't format properly into code. Please check this: https://www.notehub.org/pnlkr

Basically I want to extract Good Read ID from the Good Read URL.

Example:

URL - https://www.goodreads.com/book/show/1...

The ID here is 1. How do I get it? Is there any API end point?

If not, I can use good ol regex. So I think following are valid URL formats:

- https://www.goodreads.com/book/show/1
- https://www.goodreads.com/book/show/1...
- https://www.goodreads.com/book/show/1...
- https://www.goodreads.com/book/show/1...

So basically the format is https://www.goodreads.com/book/show/

However what if the book name itself has a number?

Take this example: 12 Monkeys

Following are valid:

- https://www.goodreads.com/book/show/8...
- https://www.goodreads.com/book/show/8...

So now regex becomes: https://www.goodreads.com/book/show/

but that again fits into: https://www.goodreads.com/book/show/

Am I right path?


message 2: by v (new)

v (avins) Don't know how to properly format code in OP. Please check this: https://www.notehub.org/pnlkr

Thank you!


message 3: by Michael (new)

Michael Economy (michaeleconomy) We may change the format of the URL at any time.


Haven't tested this extensively, but i think if you look for the first match of /(\d+?)/ that will work.


Keep in mind this could break at any moment if we make changes to our url structures.


message 4: by v (new)

v (avins) yup, thats what I thought. Thanks, I will keep in mind that you guys may change the URL.


back to top