Control Home Assistant with Python

I have a few Tuya smart light bulbs and plugs (they’re all switches in Home Assistant, because the lights are not RGB lights) configured in Home Assistant. I want to create an API with Python using the Flask-Restful library to control my lights. Does anyone have any idea how I can do this? I know how to make an API, but how will I control the lights with external Python code (outside of Home Assistant)? Is there some sort of Tuya API or Python library for this? Or maybe a Home Assistant API or library?

I’m new to Home Assistant, so is this what my configuration.yaml is supposed to look like?

# Configure a default setup of Home Assistant (frontend, api, etc)

# Text to speech
  - platform: google_translate

# DuckDNS SSL certificate stuff
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem


# Created by HASS
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

Why do you want to do this in the first place?

You don’tneed to add api:, because it is included in the frontend, which is included in default_config.