Get pokemon encounter
package main
import ( "fmt" "net/http" "io")
func main() {
url := "https://pokeapi.co/api/v2/pokemon/1/encounters"
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/pokemon/1/encounters")) .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/pokemon/1/encounters") .get() .build();
Response response = client.newCall(request).execute();import axios from 'axios';
const options = {method: 'GET', url: 'https://pokeapi.co/api/v2/pokemon/1/encounters'};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://pokeapi.co/api/v2/pokemon/1/encounters';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/pokemon/1/encounters";
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/pokemon/1/encounterswget --quiet \ --method GET \ --output-document \ - https://pokeapi.co/api/v2/pokemon/1/encountersHandles Pokemon Encounters as a sub-resource.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”A unique integer value identifying the Pokémon.
Examples
1Responses
Section titled “Responses”object
The location area the referenced Pokémon can be encountered in.
object
The name of the referenced resource.
The URL of the referenced resource.
A list of versions and encounters with the referenced Pokémon that might happen.
object
The game version this encounter happens in.
object
The name of the referenced resource.
The URL of the referenced resource.
The total percentage of all encounter potential.
A list of encounters and their specifics.
object
Percent chance that this encounter will occur.
A list of condition values that must be in effect for this encounter to occur.
object
The name of the referenced resource.
The URL of the referenced resource.
The highest level the Pokémon could be encountered at.
The method by which this encounter happens.
object
The name of the referenced resource.
The URL of the referenced resource.
The lowest level the Pokémon could be encountered at.
Example
[ { "location_area": { "name": "cerulean-city-area", "url": "https://pokeapi.co/api/v2/location-area/281/" }, "version_details": [ { "version": { "name": "yellow", "url": "https://pokeapi.co/api/v2/version/3/" }, "max_chance": 100, "encounter_details": [ { "min_level": 10, "max_level": 10, "chance": 100, "method": { "name": "gift", "url": "https://pokeapi.co/api/v2/encounter-method/18/" }, "condition_values": [], "pokemon_details": null } ] }, { "version": { "name": "lets-go-pikachu", "url": "https://pokeapi.co/api/v2/version/31/" }, "max_chance": 100, "encounter_details": [ { "min_level": 12, "max_level": 12, "chance": 100, "method": { "name": "gift", "url": "https://pokeapi.co/api/v2/encounter-method/18/" }, "condition_values": [], "pokemon_details": null } ] } ] }, { "location_area": { "name": "pallet-town-area", "url": "https://pokeapi.co/api/v2/location-area/285/" }, "version_details": [ { "version": { "name": "red", "url": "https://pokeapi.co/api/v2/version/1/" }, "max_chance": 100, "encounter_details": [ { "min_level": 5, "max_level": 5, "chance": 100, "method": { "name": "gift", "url": "https://pokeapi.co/api/v2/encounter-method/18/" }, "condition_values": [], "pokemon_details": null } ] }, { "version": { "name": "blue", "url": "https://pokeapi.co/api/v2/version/2/" }, "max_chance": 100, "encounter_details": [ { "min_level": 5, "max_level": 5, "chance": 100, "method": { "name": "gift", "url": "https://pokeapi.co/api/v2/encounter-method/18/" }, "condition_values": [], "pokemon_details": null } ] } ] }]