Package: tronald-dumpy
TronaldDump API WrapperTronalddump.iois a free API and web archive for the dumbest things Donald Trump has ever said ...You might want to check out thedocumentationfor the API before working with it.DescriptionThe package consists of two main modules:api: tools for accessing the API.parse: tools for parsing retieved data.InstallationEnsure you have Python 3 and the package managerpipinstalled.Install using pip:$pip3installtronalddumpyor, you can build the latest version from source:$gitclonehttps://github.com/Gushka/tronalddump-python.git$cdtronalddump-python/$python3setup.pyinstallBasic usageImport the main modules and create a client:fromtronalddumpimportapi,parseclient=api.TronaldDumpAPI()Now to access any API method we will use this client.For example, let us get a random quote:>>>resp=client.random_quote()>>>resp<TronaldDumpResponse:'https://www.tronalddump.io/random/quote'># Get the response data:>>>resp.data{JSON}# Get the URL:>>>resp.url'https://www.tronalddump.io/random/quote'Parsing the JSON dataUsing the TronaldDump module you also can get specific values from the API response just as easy.Create a Parser using the JSON file-object we obtained earlier:>>>parsed=parse.Parser(resp)Now we can extract all kinds of data from the JSON based on what the initial response type was.# Retrieve value of a quote:>>>parsed.value()"Money was never a big motivation for me, except as a way to keep score."# Retrieve the date it was written online:>>>parsed.date_appeared()datetime.date(2014,9,14)There's also a function to print into the console formatted JSON response.Use it only for the debugging purposes.>>> parsed.printout()DocumentationTronaldDumpAPIclass:Tagsall_tagsRetrieves all existing tags from the API.TronaldDumpAPI().all_tags()find_tagFinds a tag by its value. Given paramaters will be capitalized for the proper search indexing.TronaldDumpAPI().find_tag(value)Quotesrandom_quoteRetrieve a random quote from Troland Dump.TronaldDumpAPI().random_quote()random_memeRetrieve a random meme image with a quote Troland Dump.TronaldDumpAPI().random_meme(output_dir,filename="randommeme.png",force_write=True)output_dir: The directory where to store the image.filename: The name for the downloaded file. By default it'srandommeme.pngforce_write: Whether to overwrite already existing file or not. By default is set toTruesearch_quoteSearch for a quote by a query or tag. Returns one-page answer. You must pick eitherqueryortagparameter.
They are interchangeble and only one may be used at a time.TO BE IMPROVED:For now returns only the first page of a search answer.TronaldDumpAPI().search_quote(query=None,tag=None,page=0)query: The string which will be searched for.tag: The tag which will be searched for.page: The number of a page that will be returned.find_quoteFind a quote by its ID.TronaldDumpAPI().find_quote(id)id: The ID of a quote you're looking for.quote_sourceRetrieve the source of a quote by its ID.TronaldDumpAPI().quote_source(id)id: The ID of a quote source of which you're looking for.Authorfind_authorFind an author by their ID.TronaldDumpAPI().find_author(id)id: The ID of an author you're looking for.TronaldDumpParserclass:printoutPrints the contents of given JSON object in the formatted form.Parser().printout()Tagstag_valueRetrieve all tags values from the given JSON object in a list.Parser().tag_value()QuotesvalueRetrieve the "value" value of a given JSON object.Parser().value()authorRetrieve the "author" value of a given JSON object.Parser().author()date_appearedRetrieve the date when a given quote was written and published.Parser().date_appeared()tagsRetrieve all the tags of a given quoteParser().tags()quote_idRetrieve the "quote-id" value from the JSON objectParser().quote_id()sourceRetrieve the source of a given quoteParser().source()For full and more detailed information seehelp()on needed classes and functions.