Examples on how to use the "Send web request" and "Get image from" bricks
For important general, and especially safety related information, please see https://catrob.at/webbricks.
These bricks can be extremely dangerous, so read the information provided on this page carefully. Really!!
The "Send web request" and "Get image from" bricks allow you to access the internet in order to get some information from, e.g., wikipedia, including images from the web. Images can be directly used as looks of an object, and this can for instance be used to retrieve parts of real world maps if a web service allows to do so. Please note that many of these services require API keys, which can be either free of charge but require registration, or commercial and cost money. Make sure to read the warnings on https://catrob.at/webbricks for dangers associated with the use of these bricks.
To take full advantage of the capabilities of the web bricks, you can use the "join" function to build more complex web addresses required for accessing relevant content, as well as the "regular expression" function to extract relevant information from text your project downloaded with the "Send web request" brick.
For a comprehensive list of the capabilities of regular expressions, please consult the official documentation for the Android version of Catrobat's apps: https://developer.android.com/reference/java/util/regex/Pattern
Further documentation and help regarding advanced topics is available here.
Explanations on how to get API keys if necessary for some of the web services listed below are usually available via the address of the service. Some searching may be required.
NOTE the very important safety considerations when using API keys explained on this page.
Trusted domains:
- Current public version
- Version for the next release
- Please send corrections or suggest new entries by email to support+approveddomains@catrobat.org (please add explanations and/or sample queries).
Explanations and examples:
Title | Address | Description | Sample Catrobat projects | API key |
---|---|---|---|---|
Random jokes | https://official-joke-api.appspot.com/random_joke | The free joke api returns data in the following json format: {"id":10,"type":"general","setup":"What kind of shoes does a thief | Elephant that tells random jokes when tapped | No |
Geocoding and geoparsing | https://geocode.xyz/ | The free worldwide geocoding and geoparsing API, with a query such as | TODO: Some project that does something with geography (NOTE: this link must be corrected to a relevant example once the brick is included in the release) | No |
"hello" in various languages | https://fourtonfish.com/hellosalut/hello/ | This free service returns a json text with the word "hello" in a chosen language. | TODO: Some project that does something with the hello service (NOTE: this link must be corrected to a relevant example once the brick is included in the release) | No |
Extract pure text from HTML page | Works with any plain HTML web page. The example uses Wikipedia. | This project shows how to get the readable text part from a web page by eliminating html tags when using a "Send web request" brick. The demo uses the first descriptive paragraph from English Wikipedia pages. Test cases are also available when setting the corresponding flag in the first object. | https://share.catrob.at/app/project/3fbad7bf-f17f-11ea-9251-005056a36f47 | |