In the digital age, APIs (Application Programming Interfaces) have become the cornerstone of interaction between different software systems. However, traditional API interfacing methods are often inefficient and frustrating for developers.
Have you also faced the following dilemma:
- Documentation Skybook: The interface documentation is obscure, and the parameter descriptions are vague and confusing.
- Terminology Maze: There is an endless array of terminology, and novices need to spend a lot of time consulting information to understand it.
- Parametric black holes: The complex API documentation has many parameters and a dizzying array of configuration combinations.
- Duplication of labor: Every time you interface with a new API, you need to repeatedly read the documentation, write code, debug and test, which is time-consuming and labor-intensive.
These problems not only reduce development efficiency, but also increase the R&D costs of enterprises. To address these pain points, Dify has launched a new workflow that aims to utilize AI technology to simplify the API docking process and free developers from tedious documentation work.
Dify Workflow: The Intelligent API Assistant
Dify A workflow is like an intelligent assistant that automatically reads and understands API documentation and turns it into code and information that developers can easily use. At its core, it utilizes AI grand models to semantically parse and process API documents.
The whole process is as follows:
- Document Extraction: Dify workflows support multiple sources of API documentation:
- Local Documentation: Supports uploading documents in Word, Markdown, PDF and other formats.
- Online documentation: Supports inputting the URL of an API document to automatically crawl the content of a web page.
- API definition file: Supports direct import of API definition files in Swagger/OpenAPI format.
- Local Documentation: Supports uploading documents in Word, Markdown, PDF and other formats.
- Page Crawl: For online API documentation, Dify integrates the open-source Firecrawl tool that converts web content into Markdown format.
Firecrawl Official Website: https://www.firecrawl.dev/
Users can register an account on the Firecrawl website to get an API Key and install the appropriate plugin in Dify.
Dify supports the installation of the Firecrawl plugin, while localized deployment is also an option for those who can afford it, given the limited amount of free Firecrawl credits.
- AI model processing: Submit the extracted document content or crawled Markdown text to the AI macromodel for processing.
Dify workflows support a wide selection of AI models. Real-world testing has found that
qwen2.5-coder-32b-instruct
Models are a good choice for the following main reasons:- 128k context window, enough to handle most API documentation.
- As a code model, it is more adept at handling tasks related to code generation.
- All major modeling platforms are available and user-friendly.
- For users with high-performance GPUs (e.g., 4090, 5090), local deployment is an option for faster processing.
Of course, if you are on a budget, you can also choose
qwen2.5-coder-7b-instruct
Modeling. If optimal results are sought, thedeepseek-r1
Models are also a good choice. - Compatibility: Dify workflows support major operating systems such as Windows, macOS, and Linux, and are compatible with Python, Java, JavaScript, Go, and many other programming languages.
Through the above steps, Dify workflow can transform API documents from different sources and formats into unified text data that can be understood by AI, laying the foundation for subsequent code generation, parameter query and other functions.
API documentation to generate code: the development of the public number of micro-channel as an example
Next, take WeChat public development as an example to show how Dify workflow can simplify the API docking process.
The first step in WeChat development is usually to get an access token.
The official documentation of WeChat: https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_access_token.html
The traditional development process usually looks like this:
- Read the documentation to find the interface URL and request method.
- Determine the parameters required for the interface.
- Look for key parameters such as AppID and AppSecret in the documentation.
- Write test code.
- Run the code and debug it.
- If an error is encountered, return to the documentation to find the cause based on the error code.
With Dify workflows, the above process can be greatly simplified. Simply enter the URL of the API document in the Dify workflow interface, select a programming language (e.g. Python), and click Run.
Dify automatically parses the entire document, interprets the meaning of parameters and error codes, and generates runnable code examples.
What's more, Dify will directly give tips in the generated code comments or on the interface, telling users how to get key parameters such as AppID and AppSecret. For example, in WeChat public development, Dify will prompt the user to go to "WeChat public platform's 'Settings and Development-Basic Configuration'" to get it.
Users simply fill in the "Extra Notes" of the Dify workflow with the AppID and AppSecret they have obtained, and without any special formatting, click Run to generate usable code.
Copy the generated code into an IDE such as PyCharm and execute it to call the APIs directly, eliminating the need to manually write large amounts of code and perform tedious debugging.
In addition to generating test code, Dify also supports the use of specific development frameworks or libraries. For example, in Java development, you can use the weixin-java-mp
This commonly used WeChat development library. Users just need to make a request in Dify, even if they don't remember the full name of the library, Dify can generate the corresponding code.
In addition, Dify also supports code completion. Users can copy existing code snippets into Dify, Dify will automatically complete the code according to the context to improve development efficiency.
API Documentation Parameter Lookup
In addition to code generation, Dify workflow also provides powerful parameter query function. Users can ask questions directly in the document, such as asking the meaning of a parameter, especially for those documents that use pinyin initials as parameter names, this feature is very useful.
Dify will give accurate explanations based on the content of the documentation to help users quickly understand how to use the API.
Pricing and access
Dify offers both free and paid versions. The free version includes basic functionality and is sufficient for individual developers. The paid version provides more advanced features and technical support, and is suitable for enterprise users. Users can sign up for a free trial on the Dify website.
To experience Dify's new workflows, you can find and import DSL files in the Studio on the Dify homepage.
Summary and outlook
Dify's new workflow realizes automatic parsing of API documents, code generation and parameter query through AI technology, greatly simplifying the API docking process and improving development efficiency. Both beginners and experienced developers can benefit from Dify workflow.
In the future, Dify will continue to optimize AI models to improve the accuracy and speed of API document parsing. At the same time, Dify will also explore more application scenarios, such as API automatic testing, API performance monitoring, etc., is committed to providing developers with a more comprehensive, more intelligent API tool chain. Dify is looking forward to working with you to explore a more intelligent and efficient way of development.