MCPcopy
hub / github.com/dlt-hub/dlt / rest_api_source

Function rest_api_source

dlt/sources/rest_api/__init__.py:78–147  ·  view source on GitHub ↗

Creates and configures a REST API source for data extraction. Args: config (RESTAPIConfig): Configuration for the REST API source. name (str, optional): Name of the source. section (str, optional): Section of the configuration file. max_table_nesting (int, option

(
    config: RESTAPIConfig,
    name: str = None,
    section: str = None,
    max_table_nesting: int = None,
    root_key: bool = None,
    schema: Schema = None,
    schema_contract: TSchemaContract = None,
    parallelized: bool = False,
)

Source from the content-addressed store, hash-verified

76
77
78def rest_api_source(
79 config: RESTAPIConfig,
80 name: str = None,
81 section: str = None,
82 max_table_nesting: int = None,
83 root_key: bool = None,
84 schema: Schema = None,
85 schema_contract: TSchemaContract = None,
86 parallelized: bool = False,
87) -> DltSource:
88 """Creates and configures a REST API source for data extraction.
89
90 Args:
91 config (RESTAPIConfig): Configuration for the REST API source.
92 name (str, optional): Name of the source.
93 section (str, optional): Section of the configuration file.
94 max_table_nesting (int, optional): Maximum depth of nested table above which
95 the remaining nodes are loaded as structs or JSON.
96 root_key (bool, optional): Enables merging on all resources by propagating
97 root foreign key to child tables. This option is most useful if you
98 plan to change write disposition of a resource to disable/enable merge.
99 Defaults to False.
100 schema (Schema, optional): An explicit `Schema` instance to be associated
101 with the source. If not present, `dlt` creates a new `Schema` object
102 with provided `name`. If such `Schema` already exists in the same
103 folder as the module containing the decorated function, such schema
104 will be loaded from file.
105 schema_contract (TSchemaContract, optional): Schema contract settings
106 that will be applied to this resource.
107 parallelized (bool, optional): If `True`, resource generators will be
108 extracted in parallel with other resources. Transformers that return items are also parallelized.
109 Non-eligible resources are ignored. Defaults to `False` which preserves resource settings.
110
111 Returns:
112 DltSource: A configured dlt source.
113
114 Example:
115 pokemon_source = rest_api_source({
116 "client": {
117 "base_url": "https://pokeapi.co/api/v2/",
118 "paginator": "json_link",
119 },
120 "resources": [
121 {
122 "name": "pokemon",
123 "endpoint": {
124 "path": "pokemon",
125 "params": {
126 "limit": 100,
127 },
128 },
129 "primary_key": "id",
130 }
131 ]
132 })
133 """
134 # TODO: this must be removed when TypedDicts are supported by resolve_configuration
135 # so secrets values are bound BEFORE validation. validation will happen during the resolve process

Calls 2

_validate_configFunction · 0.85
cloneMethod · 0.45