{"id":15713725,"url":"https://github.com/henrikac/pokeapi","last_synced_at":"2025-03-30T18:47:51.934Z","repository":{"id":46118996,"uuid":"365619480","full_name":"henrikac/pokeapi","owner":"henrikac","description":"Crystal wrapper library for pokeapi.co v2","archived":false,"fork":false,"pushed_at":"2021-11-12T22:49:02.000Z","size":138,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T21:27:30.350Z","etag":null,"topics":["crystal","crystal-lang","crystal-language","pokemon"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/henrikac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-08T22:04:54.000Z","updated_at":"2024-02-29T00:32:54.000Z","dependencies_parsed_at":"2022-09-23T06:40:23.498Z","dependency_job_id":null,"html_url":"https://github.com/henrikac/pokeapi","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrikac%2Fpokeapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrikac%2Fpokeapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrikac%2Fpokeapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henrikac%2Fpokeapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/henrikac","download_url":"https://codeload.github.com/henrikac/pokeapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246365640,"owners_count":20765546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crystal","crystal-lang","crystal-language","pokemon"],"created_at":"2024-10-03T21:33:06.984Z","updated_at":"2025-03-30T18:47:51.495Z","avatar_url":"https://github.com/henrikac.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PokeAPI\n\nCrystal wrapper library for [PokéAPI](https://pokeapi.co/docs/v2).\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     pokeapi:\n       github: henrikac/pokeapi\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n#### Get a list of resources\n\nTo get a list of resources from any of the endpoints specified below use  \n\n`.resource(endpoint : String, limit : UInt32 = 20, offset : UInt32 = 0)`\n\n```crystal\nrequire \"pokeapi\"\n\n# returns a list of the first 20 pokémons\npokemons = PokeAPI.resource(\"pokemon\")\n\n# returns a list of 8 pokémons starting from #90 (if possible)\npokemons = PokeAPI.resource(\"pokemon\", limit: 8, offset: 90)\n```\n\n#### Get a single item\n\nEach of the endpoints has a corresponding method that can be used to get data from that specific endpoint, e.g.\n\n###### /pokemon/{id or name}/\n\n```crystal\nrequire \"pokeapi\"\n\npokemon_id = PokeAPI.pokemon(25) # =\u003e returns pokémon with id == 25\npokemon_name = PokeAPI.pokemon(\"eevee\") # =\u003e returns pokémon with name eevee\n```\n\n###### /growth-rate/{id or name}/\n\n```crystal\nrequire \"pokeapi\"\n\ngrowth_rate = PokeAPI.growth_rate(2) # =\u003e returns growth-rate with id == 2\n```\n\n#### Cache\n\nData retrieved from [PokéAPI](https://pokeapi.co/docs/v2) is automaticly cached in-memory. However, the cache can be turned on/off manually if needed.\n\n```crystal\nrequire \"pokeapi\"\n\nPokeAPI::CACHE.enable\nPokeAPI::CACHE.disable\n```\n\nIt is also possible to clear the cache if needed.\n\n```crystal\nrequire \"pokeapi\"\n\nPokeAPI::CACHE.clear\n```\n\nThe default time data is cached is set to 30 minutes.\n\n```crystal\nrequire \"pokeapi\"\n\nPokeAPI::CACHE.set_cache_time(45.mintues)\n```\n\n#### Errors\n\nIf no resource was found a `PokeAPI::NoResourceError` is raised.\n\n```crystal\nrequire \"pokeapi\"\n\nbegin\n  berry = PokeAPI.berry(\"weird-unknown-berry\")\nrescue ex : PokeAPI::NoResourceError\n  puts ex.status_code # =\u003e 404\n  puts ex.status_message # =\u003e Not Found\n  puts ex.message # =\u003e 404 - Not Found\nend\n```\n\n## Endpoints\n\n#### Berries\n  * Berries `/berry/{id or name}/`\n  * Berry Firmnesses `/berry-firmness/{id or name}/`\n  * Berry Flavors `/berry-flavor/{id or name}/`\n#### Contests\n  * Contest Types `/contest-type/{id or name}/`\n  * Contest Effects `/contest-effect/{id}/`\n  * Super Contest Effects `/super-contest-effect/{id}/`\n#### Encounters\n  * Encounter Methods `/encounter-method/{id or name}/`\n  * Encounter Conditions `/encounter-condition/{id or name}/`\n  * Encounter Condition Values `/encounter-condition-value/{id or name}/`\n#### Evolution\n  * Evolution Chains `/evolution-chain/{id}/`\n  * Evolution Triggers `/evolution-trigger/{id or name}/`\n#### Games\n  * Generations `/generation/{id or name}/`\n  * Pokedexes `/pokedex/{id or name}/`\n  * Version `/version/{id or name}/`\n  * Version Groups `/version-group/{id or name}/`\n#### Items\n  * Item `/item/{id or name}/`\n  * Item Attributes `/item-attribute/{id or name}/`\n  * Item Categories `/item-category/{id or name}/`\n  * Item Fling Effects `/item-fling-effect/{id or name}/`\n  * Item Pockets `/item-pocket/{id or name}/`\n#### Locations\n  * Locations `/location/{id or name}/`\n  * Location Areas `/location-area/{id or name}/`\n  * Pal Park Areas `/pal-park-area/{id or name}/`\n  * Regions `/region/{id or name}/`\n#### Machines\n  * Machines `/machine/{id}/`\n#### Moves\n  * Moves `/move/{id or name}/`\n  * Move Allments `/move-ailment/{id or name}/`\n  * Move Battle Styles `/move-battle-style/{id or name}/`\n  * Move Categories `/move-category/{id or name}/`\n  * Move Damage Classes `/move-damage-class/{id or name}/`\n  * Move Learn Methods `/move-learn-method/{id or name}/`\n  * Move Targets `/move-target/{id or name}/`\n#### Pokémon\n  * Abilities `/ability/{id or name}/`\n  * Characteristics `/characteristic/{id}/`\n  * Egg Groups `/egg-group/{id or name}/`\n  * Genders `/gender/{id or name}/`\n  * Growth Rates `/growth-rate/{id or name}/`\n  * Natures `/nature/{id or name}/`\n  * Pokeathlon Stats `/pokeathlon-stat/{id or name}/`\n  * Pokemon `/pokemon/{id or name}/`\n  * Pokemon Location Areas `/pokemon/{id or name}/encounters/`\n  * Pokemon Colors `/pokemon-color/{id or name}/`\n  * Pokemon Forms `/pokemon-form/{id or name}/`\n  * Pokemon Habitats `/pokemon-habitat/{id or name}/`\n  * Pokemon Shapes `/pokemon-shape/{id or name}/`\n  * Pokemon Species `/pokemon-species/{id or name}/`\n  * Stats `/stat/{id or name}/`\n  * Types `/type/{id or name}/`\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/henrikac/pokeapi/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Henrik Christensen](https://github.com/henrikac) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrikac%2Fpokeapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenrikac%2Fpokeapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenrikac%2Fpokeapi/lists"}