A communication method, comprising: receiving, by a common application programming interface framework core function, CCF, network element, an application programming interface, API, publish request message from an API publishing network element, wherein the API publish request message comprises a correspondence between network slice information and API information; receiving, by the CCF network element, an API discover request message from an API invoker network element, wherein the API discover request message comprises an API inquiry parameter and reference information of an application; after the receiving, by the CCF network element, the API discover request message from the API invoker network element, the method further comprises: sending (201, 303a), by the CCF network element, the reference information of the application to a first network element; and receiving (203, 303c), by the CCF network element from the first network element, network slice information corresponding to the application; and after the receiving, by the CCF network element from the first network element, the network slice information corresponding to the application, the method further comprises: determining, by the CCF network element based on the correspondence between the network slice information and the API information, the network slice information corresponding to the application, and the API inquiry parameter, target API information corresponding to the application, wherein an API corresponding to the target API information is to-be-invoked by the API invoker network element; and sending, by the CCF network element, the network slice information and the target API information to the API invoker network element. receiving, by a common application programming interface framework core function, CCF, network element, an application programming interface, API, publish request message from an API publishing network element, wherein the API publish request message comprises a correspondence between network slice information and API information; receiving, by the CCF network element, an API discover request message from an API invoker network element, wherein the API discover request message comprises an API inquiry parameter and reference information of an application; after the receiving, by the CCF network element, the API discover request message from the API invoker network element, the method further comprises: sending (201, 303a), by the CCF network element, the reference information of the application to a first network element; and receiving (203, 303c), by the CCF network element from the first network element, network slice information corresponding to the application; and after the receiving, by the CCF network element from the first network element, the network slice information corresponding to the application, the method further comprises: determining, by the CCF network element based on the correspondence between the network slice information and the API information, the network slice information corresponding to the application, and the API inquiry parameter, target API information corresponding to the application, wherein an API corresponding to the target API information is to-be-invoked by the API invoker network element; and sending, by the CCF network element, the network slice information and the target API information to the API invoker network element. sending (201, 303a), by the CCF network element, the reference information of the application to a first network element; and receiving (203, 303c), by the CCF network element from the first network element, network slice information corresponding to the application; and after the receiving, by the CCF network element from the first network element, the network slice information corresponding to the application, the method further comprises: determining, by the CCF network element based on the correspondence between the network slice information and the API information, the network slice information corresponding to the application, and the API inquiry parameter, target API information corresponding to the application, wherein an API corresponding to the target API information is to-be-invoked by the API invoker network element; and sending, by the CCF network element, the network slice information and the target API information to the API invoker network element. determining, by the CCF network element based on the correspondence between the network slice information and the API information, the network slice information corresponding to the application, and the API inquiry parameter, target API information corresponding to the application, wherein an API corresponding to the target API information is to-be-invoked by the API invoker network element; and sending, by the CCF network element, the network slice information and the target API information to the API invoker network element.