trustcafe-api-wrapper/development.md
2026-04-16 21:08:54 +01:00

2 KiB

Things to think about do

Debates

  1. Hating the name jobs and run_job. Requests is an existing package dependency though. tasks seems to broard. I'm sure there's probably an already existing name that I can't articulate how to find. apirequests, rqsts, apicalls?
  2. Should these job be called with dot notation? Or with slashes? Or something else? Is it okay to have these as strings?
  3. Should we do validation in the jobs or let the server do that all?
  4. wrapped is an awkward name. What's more proper? But also obvious?
  5. Should have consistent format, ie create_{noun}, and delete_{noun}, rather than just verbing ie comment, post as this is ambiguousetc
  6. Known/displayed entity names or as-is/DB names, ie: trust or reltrust? We call trust as reltrust in the database and in the backend, relfollow for follow, but don't have relblock, instead it's userblock. It's a bit inconsistent and not very obvious at all.
    Feels helpful to make it more obvious inside the wrapper but is also potentially misleading.

ToDo:

  1. Make more jobs
  2. Make more wrappers
  3. Write more documentation
  4. Wrappers should also accept actual keys for when you know them
  5. Use this:
try:
        # NOTE: Maybe define self.session = requests.Session() in an __init__ or similar and use it here instead of the 'with' block for better performance.
        # Session for connection pooling and performance improvement
        with requests.Session() as session:
            # Update session headers once instead of every request
            session.headers.update(headers)

            # GET requests to fetch normal and removed posts
            res_n = session.get(url_normal, timeout=60)
            # res_r = session.get(url_removed, timeout=60)

            # Checking if both requests are good before proceeding
            res_n.raise_for_status()
            # res_r.raise_for_status()

Trust Follow Mute Block

Remvoved posts