API(应用程序编程接口)是开发人员必不可少的工具,允许他们将第三方服务集成到他们的应用程序中。以下是 2024 年各个类别中可用的免费 API 的详细列表,以及每个 API 的网站链接、描述和示例代码。
游戏 API
Steam 社区 API
网站:steamcommunity.com/dev
描述:Steamworks Web API 提供了各种 Steam 功能的接口,例如用户身份验证、库存管理和游戏数据。
示例代码
const fetch = require('node-fetch'); const steamApiKey = 'YOUR_STEAM_API_KEY'; const steamId = 'STEAM_USER_ID'; const url = `http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=${steamApiKey}&steamids=${steamId}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
防暴游戏 API
网站:developer.riotgames.com
描述:访问《英雄联盟》、《云顶之弈》、《Valorant》等游戏的数据。提供比赛、排名、冠军以及其他游戏相关统计数据。
示例代码
const fetch = require('node-fetch'); const riotApiKey = 'YOUR_RIOT_API_KEY'; const summonerName = 'SUMMONER_NAME'; const url = `https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/${summonerName}?api_key=${riotApiKey}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
语言API
邪恶侮辱生成器 API
网站:evilinsult.com/api
描述:以各种语言生成随机侮辱,用于娱乐或测试目的。
示例代码
const fetch = require('node-fetch'); const url = 'https://evilinsult.com/generate_insult.php?lang=en&type=json'; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
趣味翻译 API
网站:funtranslations.com/api
描述:将文本翻译成各种有趣的语言,如尤达、莎士比亚、小黄人语等。
示例代码
const fetch = require('node-fetch'); const text = 'Hello, world!'; const url = `https://api.funtranslations.com/translate/yoda.json?text=${encodeURIComponent(text)}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
音乐 API
Spotify 网络 API
网站:developer.spotify.com/documentation/web-api
描述:访问音乐数据,例如专辑、艺术家、播放列表和用户数据。控制 Spotify 播放等。
示例代码
const fetch = require('node-fetch'); const accessToken = 'YOUR_SPOTIFY_ACCESS_TOKEN'; const url = 'https://api.spotify.com/v1/me/player/recently-played'; fetch(url, { headers: { 'Authorization': `Bearer ${accessToken}` } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
安全API
我被盗了吗 API
网站:haveibeenpwned.com/API/v2
描述:检查您的电子邮件或用户名是否属于数据泄露的一部分。提供有关违规、粘贴和密码泄露的数据。
示例代码
const fetch = require('node-fetch'); const email = 'test@example.com'; const url = `https://haveibeenpwned.com/api/v2/breachedaccount/${email}`; fetch(url, { headers: { 'User-Agent': 'Node.js' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
首丹API
网站:developer.shodan.io
描述:Shodan 是一个用于互联网连接设备的搜索引擎。它提供全球各种服务器、设备和系统的数据。
示例代码
const fetch = require('node-fetch'); const steamApiKey = 'YOUR_STEAM_API_KEY'; const steamId = 'STEAM_USER_ID'; const url = `http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=${steamApiKey}&steamids=${steamId}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
科学与数学 API
美国宇航局应用程序编程接口
网站:api.nasa.gov
描述:访问 NASA 数据集中的数据,包括天文照片、行星数据等。
示例代码
const fetch = require('node-fetch'); const riotApiKey = 'YOUR_RIOT_API_KEY'; const summonerName = 'SUMMONER_NAME'; const url = `https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/${summonerName}?api_key=${riotApiKey}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
Wolfram Alpha API
网站:products.wolframalpha.com/api
描述:提供对 Wolfram Alpha 的大量计算知识的访问,包括数学计算、数据分析等。
示例代码
const fetch = require('node-fetch'); const url = 'https://evilinsult.com/generate_insult.php?lang=en&type=json'; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
开放科学框架 API
网站:developer.osf.io
描述:从开放科学框架访问研究数据、项目管理工具和其他科学资源。
示例代码
const fetch = require('node-fetch'); const text = 'Hello, world!'; const url = `https://api.funtranslations.com/translate/yoda.json?text=${encodeURIComponent(text)}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
体育 API
NBA应用程序接口
网站:any-api.com/nba_com/nba_com/docs/API_Description
描述:访问 NBA 球队、球员和比赛的数据。
示例代码
const fetch = require('node-fetch'); const accessToken = 'YOUR_SPOTIFY_ACCESS_TOKEN'; const url = 'https://api.spotify.com/v1/me/player/recently-played'; fetch(url, { headers: { 'Authorization': `Bearer ${accessToken}` } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
网络应用 API
不和谐 API
网站:discord.com/developers/docs/intro
描述:将您的应用程序与 Discord 集成,允许用户身份验证、消息传递等。
示例代码
const fetch = require('node-fetch'); const email = 'test@example.com'; const url = `https://haveibeenpwned.com/api/v2/breachedaccount/${email}`; fetch(url, { headers: { 'User-Agent': 'Node.js' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
松弛API
网站:api.slack.com
描述:访问 Slack 功能,例如消息传递、用户数据和工作区管理。
示例代码
const fetch = require('node-fetch'); const shodanApiKey = 'YOUR_SHODAN_API_KEY'; const query = 'apache'; const url = `https://api.shodan.io/shodan/host/search?key=${shodanApiKey}&query=${query}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
产品和事物 API
汽车查询API
网站:carqueryapi.com
描述:访问汽车数据,包括
品牌、型号和年份信息。
示例代码
const fetch = require('node-fetch'); const nasaApiKey = 'YOUR_NASA_API_KEY'; const url = `https://api.nasa.gov/planetary/apod?api_key=${nasaApiKey}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
叫喊 API
网站:yelp.com/developers
描述:访问本地商家的数据,包括评论、评级和商家详细信息。
示例代码
const fetch = require('node-fetch'); const wolframAppId = 'YOUR_WOLFRAM_APP_ID'; const query = 'integrate x^2'; const url = `http://api.wolframalpha.com/v2/query?input=${encodeURIComponent(query)}&appid=${wolframAppId}&output=json`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
健康API
医疗保健.gov API
网站:healthcare.gov/developers
描述:访问医疗保健计划、提供者目录和其他健康相关信息的数据。
示例代码
const fetch = require('node-fetch'); const steamApiKey = 'YOUR_STEAM_API_KEY'; const steamId = 'STEAM_USER_ID'; const url = `http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=${steamApiKey}&steamids=${steamId}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
政府和地理 API
代码.gov API
网站:code.gov
描述:访问联邦政府软件项目的数据,包括代码存储库和项目详细信息。
示例代码
const fetch = require('node-fetch'); const riotApiKey = 'YOUR_RIOT_API_KEY'; const summonerName = 'SUMMONER_NAME'; const url = `https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/${summonerName}?api_key=${riotApiKey}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
数据政府API
网站:data.gov/developers/apis
描述:访问来自美国政府的各种数据集,包括天气、教育和健康数据。
示例代码
const fetch = require('node-fetch'); const url = 'https://evilinsult.com/generate_insult.php?lang=en&type=json'; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
数据.europa.eu API
网站:data.europa.eu/en
描述:访问欧盟机构和团体的开放数据。
示例代码
const fetch = require('node-fetch'); const text = 'Hello, world!'; const url = `https://api.funtranslations.com/translate/yoda.json?text=${encodeURIComponent(text)}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
传输定位API
网站:rapidapi.com/transloc/api/openapi-1-2/details
描述:访问实时公共交通数据,包括到达预测、车辆位置等。
示例代码
const fetch = require('node-fetch'); const accessToken = 'YOUR_SPOTIFY_ACCESS_TOKEN'; const url = 'https://api.spotify.com/v1/me/player/recently-played'; fetch(url, { headers: { 'Authorization': `Bearer ${accessToken}` } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
食品原料药
开放食品事实 API
网站:world.openfoodfacts.org/data
描述:访问全球食品数据,包括成分、营养成分和过敏原信息。
示例代码
const fetch = require('node-fetch'); const email = 'test@example.com'; const url = `https://haveibeenpwned.com/api/v2/breachedaccount/${email}`; fetch(url, { headers: { 'User-Agent': 'Node.js' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
塔克花式 API
网站:github.com/evz/tacofancy-api
描述:访问玉米卷食谱数据,包括成分和制备方法。
示例代码
const fetch = require('node-fetch'); const shodanApiKey = 'YOUR_SHODAN_API_KEY'; const query = 'apache'; const url = `https://api.shodan.io/shodan/host/search?key=${shodanApiKey}&query=${query}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
开源项目 API
图书馆.io API
网站:libraries.io/api
描述:访问开源项目的数据,包括依赖信息、版本历史记录等。
示例代码
const fetch = require('node-fetch'); const nasaApiKey = 'YOUR_NASA_API_KEY'; const url = `https://api.nasa.gov/planetary/apod?api_key=${nasaApiKey}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
电影和漫画 API
查克·诺里斯笑话 API
网站:api.chucknorris.io
描述:访问查克·诺里斯笑话集。
示例代码
const fetch = require('node-fetch'); const wolframAppId = 'YOUR_WOLFRAM_APP_ID'; const query = 'integrate x^2'; const url = `http://api.wolframalpha.com/v2/query?input=${encodeURIComponent(query)}&appid=${wolframAppId}&output=json`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
最终空间 API
网站:finalspaceapi.com
描述:访问《最终太空》电视节目的数据,包括角色、剧集等。
示例代码
const fetch = require('node-fetch'); const steamApiKey = 'YOUR_STEAM_API_KEY'; const steamId = 'STEAM_USER_ID'; const url = `http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=${steamApiKey}&steamids=${steamId}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
木津API
网站:kitsu.docs.apiary.io
描述:访问动漫和漫画的数据,包括系列信息、评论和用户评分。
示例代码
const fetch = require('node-fetch'); const riotApiKey = 'YOUR_RIOT_API_KEY'; const summonerName = 'SUMMONER_NAME'; const url = `https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/${summonerName}?api_key=${riotApiKey}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
漫威API
网站:developer.marvel.com
描述:访问有关 Marvel 漫画、角色和创作者的数据。
示例代码
const fetch = require('node-fetch'); const url = 'https://evilinsult.com/generate_insult.php?lang=en&type=json'; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
戳API
网站:pokeapi.co
描述:访问神奇宝贝的数据,包括物种、能力和游戏信息。
示例代码
const fetch = require('node-fetch'); const text = 'Hello, world!'; const url = `https://api.funtranslations.com/translate/yoda.json?text=${encodeURIComponent(text)}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
瑞克和莫蒂 API
网站:rickandmortyapi.com
描述:访问瑞克和莫蒂电视节目的数据,包括角色、剧集和地点。
示例代码
const fetch = require('node-fetch'); const accessToken = 'YOUR_SPOTIFY_ACCESS_TOKEN'; const url = 'https://api.spotify.com/v1/me/player/recently-played'; fetch(url, { headers: { 'Authorization': `Bearer ${accessToken}` } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
辛普森一家行情 API
网站:thesimpsonsquoteapi.glitch.me
说明:访问《辛普森一家》电视节目中的台词集。
样本
代码
const fetch = require('node-fetch'); const email = 'test@example.com'; const url = `https://haveibeenpwned.com/api/v2/breachedaccount/${email}`; fetch(url, { headers: { 'User-Agent': 'Node.js' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
星球大战 API
网站:swapi.tech
描述:访问星球大战宇宙的数据,包括电影、角色、星际飞船和行星。
示例代码
const fetch = require('node-fetch'); const shodanApiKey = 'YOUR_SHODAN_API_KEY'; const query = 'apache'; const url = `https://api.shodan.io/shodan/host/search?key=${shodanApiKey}&query=${query}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
超级英雄API
网站:superheroapi.com
描述:访问各种超级英雄的数据,包括他们的力量、传记和图像。
示例代码
const fetch = require('node-fetch'); const nasaApiKey = 'YOUR_NASA_API_KEY'; const url = `https://api.nasa.gov/planetary/apod?api_key=${nasaApiKey}`; fetch(url) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error));
结论
这份 2024 年免费 API 的完整列表涵盖了广泛的类别,为开发人员提供了大量机会,通过强大且多样化的功能来增强其应用程序。从游戏和音乐到科学和政府数据,这些 API 为创建创新且引人入胜的项目提供了宝贵的资源。
随意探索这些 API 并将它们集成到您的项目中以解锁新的可能性和功能。快乐编码!
? 与我们保持联系!
我们正在建立一个创新蓬勃发展、技术爱好者共同成长的社区。与我们一起踏上启发、学习和创造的旅程!
?探索更多:
- Discord:与技术爱好者联系
- WhatsApp:获取实时更新
- 电报:每日见解和提示
?关注我们,获取每日灵感:
- Instagram:@thecampuscoders
- LinkedIn: @thecampuscoders
- Facebook: @thecampuscoders
? 随时访问我们!
? thecampuscoders.com
?探索资源、教程和更新,为您的技术之旅提供动力!
✨ 让我们一起协作、学习、共创未来!
有想法或建议吗?联系我们,成为非凡事业的一部分!
?联系我们: deepak@thecampuscoders.com
以上是4 中您需要了解的免费 API的详细内容。更多信息请关注PHP中文网其他相关文章!

JavaScript核心数据类型在浏览器和Node.js中一致,但处理方式和额外类型有所不同。1)全局对象在浏览器中为window,在Node.js中为global。2)Node.js独有Buffer对象,用于处理二进制数据。3)性能和时间处理在两者间也有差异,需根据环境调整代码。

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

Python和JavaScript的主要区别在于类型系统和应用场景。1.Python使用动态类型,适合科学计算和数据分析。2.JavaScript采用弱类型,广泛用于前端和全栈开发。两者在异步编程和性能优化上各有优势,选择时应根据项目需求决定。

选择Python还是JavaScript取决于项目类型:1)数据科学和自动化任务选择Python;2)前端和全栈开发选择JavaScript。Python因其在数据处理和自动化方面的强大库而备受青睐,而JavaScript则因其在网页交互和全栈开发中的优势而不可或缺。

Python和JavaScript各有优势,选择取决于项目需求和个人偏好。1.Python易学,语法简洁,适用于数据科学和后端开发,但执行速度较慢。2.JavaScript在前端开发中无处不在,异步编程能力强,Node.js使其适用于全栈开发,但语法可能复杂且易出错。

javascriptisnotbuiltoncorc; saninterpretedlanguagethatrunsonenginesoftenwritteninc.1)javascriptwasdesignedAsalightweight,解释edganguageforwebbrowsers.2)Enginesevolvedfromsimpleterterterpretpreterterterpretertestojitcompilerers,典型地提示。

JavaScript可用于前端和后端开发。前端通过DOM操作增强用户体验,后端通过Node.js处理服务器任务。1.前端示例:改变网页文本内容。2.后端示例:创建Node.js服务器。

选择Python还是JavaScript应基于职业发展、学习曲线和生态系统:1)职业发展:Python适合数据科学和后端开发,JavaScript适合前端和全栈开发。2)学习曲线:Python语法简洁,适合初学者;JavaScript语法灵活。3)生态系统:Python有丰富的科学计算库,JavaScript有强大的前端框架。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

Atom编辑器mac版下载
最流行的的开源编辑器

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

禅工作室 13.0.1
功能强大的PHP集成开发环境

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

Dreamweaver Mac版
视觉化网页开发工具