Skip to main content

Python wrapper for the Urban Dictionary API.

Project description

python-urbandict

version versions Python package codecov

This is a python project, that fetches definitions of words from urban dictionary's public API.

Future additions. PRs are always welcome :)

  • Calculate ratio of thumbs_up and thumbs_down and decide the probability of a correct definition.

Installation

Python 3.9 or higher is required

To install the library you can use the following command:

# Linux/MacOS
python3 -m pip install --upgrade python-urbandict

# Windows
py -3 -m pip install --upgrade python-urbandict

Or just try:

pip install python-urbandict

Quick Example

You can create an instance of the UrbanDict class and pass a word to it. After that you can use the search method that will retrieve the definitions from UrbanDictionary. If you want to you can also leave the word attribute empty, in which case a random word is selected by UrbanDictionary.

from pyurbandict import UrbanDict

word = UrbanDict("python")
results = word.search()
print(results[0])

>>> Definition(
    word='python',
    definition='The best thing to happen to [Computer Science] students in a data and [file] structures or [algorithms] class.',
    example='Joe: "Man...I spent a week coding that [algorithm] in C."\r\nMoe: "I got it [done in one] evening with [Python]. It works great."\r\nJoe: "Say, what? Where can I download that?"',
    author='TheNextBillGates',
    thumbs_up=243,
    thumbs_down=71,
    sound_urls=['https://api.twilio.com/2008-08-01/Accounts/ACd09691b82112e4b26fce156d7c01d0ed/Recordings/RE7065a4ef810937cc16ae2b6e4b54b67d'],
    written_on='2010-03-24T05:24:18.000Z',
    permalink='http://python.urbanup.com/4826760',
    defid=4826760,
    current_vote=''
)

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_urbandict-0.2.5.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_urbandict-0.2.5-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file python_urbandict-0.2.5.tar.gz.

File metadata

  • Download URL: python_urbandict-0.2.5.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for python_urbandict-0.2.5.tar.gz
Algorithm Hash digest
SHA256 247d2764b371211c24db8785da54003eb0e2c6219170bd3cf2825eb069ec20f4
MD5 e357186d24dba1d77b0dafd803857ee6
BLAKE2b-256 c6f85ae5d2facbfc96643065e9e6905ae5b4b771e2ca6ece93fe403867dbf768

See more details on using hashes here.

File details

Details for the file python_urbandict-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for python_urbandict-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b9b17c3b6923a1ecc216d15f77ddc743cfd839b7a81f04beaf8433d1240a9a90
MD5 84fcbb132dabcc621316603759f2f27a
BLAKE2b-256 a1c936d555867b574ad57854bb8a6eb4e41a0fe3251c870e139c1f916112dc17

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page