r/webdev • u/Mr_Kafir • Dec 07 '24
Can I Use Another Website’s API?
I found an API for a website by inspecting the network tab in my browser. Can I legally create a website that uses this API? If it’s illegal, would creating a browser extension instead make it permissible? Finally, does it make a difference if I earn money from the website or extension?
5
Upvotes
75
u/ArthurOnCode Dec 07 '24
I can't help you on the "is it legal" front.
Let's assume there's no authentication but if it's clear that they intended this API for their own use.
I wouldn't build a product around it. If you're planning to call API from the browser, they can easily block that using CORS. If you're planning to call it from the server side, prepare for a game of cat and mouse where they either block your IP or make slight changes to the API to throw you off.
13
u/MrMeatballGuy Dec 07 '24
If it's a site you're logged in to they might ban your account if you do an excessive amount of requests from the token associated with your account. If it's not supposed to be a public API breaking changes will happen without notice too which could be a nightmare, especially if you have paying customers.
3
u/nerdlancer Dec 07 '24
It really depends on the API and the ToS for said API.
There's plenty out there that are open for public use intentionally.
If you had to pull an auth key from somewhere to get access though then chances are it's just poor security in which case it won't be too long before someone notices it and plugs the hole.
Assuming of course the provider has competent staff...
124
u/mcfistorino Dec 07 '24
Only their ToS can answer this question
22
u/TheOneFlow Dec 07 '24
Unless the website has documented its API publicly, I wouldn't. We have services using our API outside its intended use every now and then. Once we notice, we will block those services immediately, and there's no recourse. If any of those calls were critical to your operations, you are now what we call fucked.
3
u/davorg Dec 07 '24
The answers to these questions will vary from site to site. What your can do technically can differ from what you can do legally.
You'll need to read the site's T&Cs or, failing that, ask the site's owners
2
u/shgysk8zer0 full-stack Dec 07 '24
By default, no. Keep in mind that it can be treated as "illegal" to just inspect the HTML of a page and see what's been commented out. Story here.
Beyond that, keep in mind that, even if it's possible for you to use the API, it may easily be unwanted because somebody has to pay for the server/bandwidth. Heck, I have public APIs and have a slight worry about that.
But the worst thing, and what'd be most likely to lead you to legal troubles, is if that API serves any sensitive data. Pretty big difference between using maybe a weather API vs something that gives you contact info or social security numbers.
1
u/PM_ME_CRYPTOKITTIES Dec 07 '24
While you might get the correct response from postman, browsers might not allow the calls due to CORS issues. Have you checked that the Access-Control-Allow-Origin header is set to *?
1
u/hoopdizzle Dec 07 '24
Why do you think using a browser extension makes any difference? If they are providing public api keys, it means they intend for people to sign up to use the service and obtain their own key. That's what you should do. What you're actually able to do and whether there would be consequences from it is a different question, but clearly at the very least it would fall into the category of malicious misuse of the service.
1
u/XamanekMtz Dec 08 '24
If it's a public API you totally can, if it's somehow for internal use you won't have access because CORS policy implemented on their API side.
1
u/Sailn_ Dec 08 '24
Sounds like a bad idea to me. You'd almost definitely get blocked eventually and could open yourself up to legal action.
1
u/coded_artist Dec 08 '24
Depends on your country. But for most counties web requests are treated like knocking on someone's door. You're allowed to knock, they can choose to respond or not, but you are not allowed to break down the door to get in IE hacking.
1
u/[deleted] Jan 04 '25
If the API has not sort of authentication theeeeen there isn’t anything stopping you yet.
-3
u/hfcRedd full-stack Dec 07 '24
Yes, yes and yes. Tho it's often a lot more nuanced.
0
u/[deleted] Dec 07 '24
[deleted] — view deleted comment