An API (Application Programming Interface) is a set of rules and endpoints that lets programs or scripts communicate with each other. In web development, APIs usually mean "web APIs"—services you can call over the network to send or receive data.
Use fetch() (modern) or XMLHttpRequest (legacy) to make HTTP requests from JS.
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => response.json())
.then(data => console.log(data));
.json(), .text(), etc. to get the data out
fetch("https://api.example.com/data")
.then(res => res.json())
.then(data => {/* use data */});
fetch('https://jsonplaceholder.typicode.com/posts', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ title: 'Hello', body: 'World', userId: 1 })
})
.then(res => res.json())
.then(data => console.log(data));
.catch() or try/catch with async/await)