`url` module of the library. Functions related to URL construction
from fastcore.test import test_eq
from nbdev.showdoc import *

URL Construction Functions

url_path_query[source]

url_path_query(path:str, cntry:str=None, pgid:str=None, lang=None, extra=None, month=None, day=None, api_key='your_api_key')

Builds and returns a string url to query path for cntry with optional pgid,extra,month and day.

url_path_query is a generic low-level function. It requires specification of required path and if used without other specific arguments, returns over 17000 records.

cntry is a two-letter country code as was specified in FIPS 10-4 (US Federal Information Processing Standard), which is now absolete a bit differs from the international ISO 3166 standard. See details.

The library provides a helper function to work around the current ambiguity.

pgid is a string with people group id.

extra is an optional argument in a form field=value, for example: 'LeastReached=Y'

month and day are optional arguments of type int or str used in url_upgotd to specify the date for which to request the unreached people group. If either is omitted, the value of the current date is used. If int values are passed, these are coverted to proper str.

test_eq(url_path_query('/api/v2/people_groups'),
        f'https://joshuaproject.net/api/v2/people_groups?&api_key={api_key}')

url_path_query is a generic function. More specific functions are described below.

url_upgotd[source]

url_upgotd(cntry:str=None, pgid:str=None, lang=None, extra=None, month=None, day=None, api_key='your_api_key')

Get data for the Unreached People Group of the Day.

m, d = date.today().strftime("%-m"), date.today().strftime("%-d")

# Today
test_eq(url_upgotd(),
    f'https://joshuaproject.net/api/v2/upgotd?&LRofTheDayMonth={m}&LRofTheDayDay={d}&api_key={api_key}')

# Any `month` and `day`
test_eq( url_upgotd(month=10, day=1),
    f'https://joshuaproject.net/api/v2/upgotd?&LRofTheDayMonth=10&LRofTheDayDay=1&api_key={api_key}')

# Current month, specific `day`
test_eq( url_upgotd(day='15'),
    f'https://joshuaproject.net/api/v2/upgotd?&LRofTheDayMonth={m}&LRofTheDayDay={15}&api_key={api_key}')

url_pgs_cntry[source]

url_pgs_cntry(cntry:str=None, pgid:str=None, lang=None, extra=None, month=None, day=None, api_key='your_api_key')

Get all people groups in a specific cntry country.

Note, since cntry is the first positional argument, it can be passed by value only.

country = 'EN'
test_eq(url_pgs_cntry(country),
    f'https://joshuaproject.net/api/v2/people_groups?ROG3={country}&api_key={api_key}')

url_upgs_cntry[source]

url_upgs_cntry(cntry:str=None, pgid:str=None, lang=None, extra='LeastReached=Y', month=None, day=None, api_key='your_api_key')

Get all unreached people groups in a specific cntry country.

country='IN'
test_eq(url_upgs_cntry(country),
    f'https://joshuaproject.net/api/v2/people_groups?ROG3={country}&LeastReached=Y&api_key={api_key}')

url_pg_cntry[source]

url_pg_cntry(cntry:str=None, pgid:str=None, lang=None, extra=None, month=None, day=None, api_key='your_api_key')

Get a specific people group in a specific cntry country.

country='RS'
test_eq(url_pg_cntry(cntry=country),
    f'https://joshuaproject.net/api/v2/people_groups?ROG3={country}&api_key={api_key}')

People group is to be encoded as PeopleID3 -- People-Group-Across-Countries ID number.

url_pg_cntries[source]

url_pg_cntries(cntry:str=None, pgid:str=None, lang=None, extra=None, month=None, day=None, api_key='your_api_key')

Get all countries a specific pgid people group lives in

pgid=18859
test_eq(url_pg_cntries(pgid=pgid),
    f'https://joshuaproject.net/api/v2/people_groups?&PeopleID3={pgid}&api_key={api_key}')

url_cntry[source]

url_cntry(cntry:str=None, pgid:str=None, lang=None, extra=None, month=None, day=None, api_key='your_api_key')

Get summary data for cntry.

country = 'BD'
test_eq(url_cntry(country),
    f'https://joshuaproject.net/api/v2/countries?ROG3={country}&api_key={api_key}')

url_lang[source]

url_lang(cntry:str=None, pgid:str=None, lang=None, extra=None, month=None, day=None, api_key='your_api_key')

Get summary data for lang language.

lang = 'hau'
test_eq(url_lang(lang=lang),
    f'https://joshuaproject.net/api/v2/languages?&ROL3={lang}&api_key={api_key}')