List locations
GET
/api/v2/location/
package main
import ( "fmt" "net/http" "io")
func main() {
url := "https://pokeapi.co/api/v2/location/"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://pokeapi.co/api/v2/location/")) .method("GET", HttpRequest.BodyPublishers.noBody()) .build();HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder() .url("https://pokeapi.co/api/v2/location/") .get() .build();
Response response = client.newCall(request).execute();import axios from 'axios';
const options = {method: 'GET', url: 'https://pokeapi.co/api/v2/location/'};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://pokeapi.co/api/v2/location/';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use reqwest;
#[tokio::main]pub async fn main() { let url = "https://pokeapi.co/api/v2/location/";
let client = reqwest::Client::new(); let response = client.get(url) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request GET \ --url https://pokeapi.co/api/v2/location/wget --quiet \ --method GET \ --output-document \ - https://pokeapi.co/api/v2/location/Locations that can be visited within the games. Locations make up sizable portions of regions, like cities or routes.
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”limit
integer
Number of results to return per page.
offset
integer
The initial index from which to return the results.
q
string
Only available locally and not at pokeapi.co Case-insensitive query applied on the
nameproperty.
Responses
Section titled “Responses”Media typeapplication/json
object
count
required
integer
next
string format: uri
previous
string format: uri
results
required
Array<object>
object
name
required
string
url
required
string format: uri
Example
{ "count": 123, "next": "http://api.example.org/accounts/?offset=400&limit=100", "previous": "http://api.example.org/accounts/?offset=200&limit=100"}