I am needing help in adding parameters in API command for api's such Urban Dictionary (for searching definitions) and open weather map (to get weather of certain location) I understand the fact that a lot of these are provided with code for querystring then ("GET", url, headers=headers, params=querystring) but I don't understand how to allow something such as $urban yo-yo.
@commands.command(
name="urban",
description="Allows the user to get a definition from Urban Dictionary",
aliases=['urbandict']
)
async def urban(self, ctx):
url = "https://mashape-community-urban-dictionary.p.rapidapi.com/define"
headers = {
'x-rapidapi-key': self.bot.quote_api_key,
'x-rapidapi-host': "mashape-community-urban-dictionary.p.rapidapi.com"
}
async with ClientSession() as session:
async with session.get(url, headers=headers) as response:
r = await response.json()
# print(r)
embed = discord.Embed(title="Term:", description=f"{r['']}")
embed.add_field(name="Definition:", value=f"||{r['']}||")
embed.set_author(name=ctx.author.display_name, icon_url=ctx.message.author.avatar_url)
await ctx.send(embed=embed)