API design question - `Response.url`
See original GitHub issueCurrently our Response.url
attribute exposes a URL
instance.
This is a breaking change from the requests API where it just exposes a plain string.
It’s feasible that we should instead only be exposing plain string URLs, in order to aim for drop-in replacement API compatibility w/ requests, and in order to keep the API surface area low.
Options here are:
- Expose
request.url
as a URL instance. (Richer information, URL class is also useful in its own right.) - Expose
request.url
as a str. (Better API compat. Lower API surface area to maintain.) - Expose
request.url
as a str, andrequest.urlinfo
as a URL instance. (Better API compat. High API surface area.)
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Best practices for REST API design - Stack Overflow Blog
Learn how to design REST APIs to be easy to understand for anyone, future-proof, secure, and fast since they serve data to clients...
Read more >Answers To The Most Common REST API Interview Questions
The most commonly asked REST API interview questions to prep for system design, software engineering, and other technical interviews.
Read more >Best Practices for Designing a Pragmatic RESTful API
An API is a user interface for a developer. Learn the best practices to make an API that is easy to adopt and...
Read more >Top REST API Interview Questions and Answers (2023)
REST is based on the Request-Response Model. Web Socket follows the full-duplex model. Every request will have sections like header, title, body, URL,...
Read more >13 API Design Interview Questions to Ask Developers ... - Twine
This article will cover some of the more common API Design interview questions, paired with some top-notch answers.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If we do keep it as a URL instance, then one option to keep closer API compat would be to allow string comparisons, eg
URL(“https://www.encode.io/“) == “https://www.encode.io/“
That has the advantage of being string-like, and far less likely to introduce any API breakage.
Seems like it’s probably the best all round option yeah.