There is a difference between API Name of the fields and the field name in Salesforce. For standard fields, the field name is used as API name in SOQL statements and for custom objects, the API Name of the fields are used in SOQL statements. Field name or label is that which displayed on page layouts for users and API name is used for coding and integration for developer.
How to know API Name of Fields
To know API name for a standard object navigate to Setup | Customize | Object | Fields.
Here we are getting to know API name for Standard Object Accounts. Click on Fields as shown above.
Now go to Standard fields section and we get some list of Standard fields as shown above. The field name is the API name for custom object fields.
API name for Account Custom Fields
To know API name for Account custom fields navigate to Accounts custom field & relationships.
Here we find API name for Account custom fields are added with __c at the end. For Custom object, custom field the API name is appended at the end.
API name for Custom Objects and Custom fields in Salesforce
Navigate to Build | Create | Object .
Now select any custom object. The API name for custom object is present in the object definition page. Open object definition page as show above. The API name for custom object Hospital is Hospital__c.
To know API name for Custom fields navigate to Build | Create | Object | Custom fields & Relationships.
The API name column in the Custom fields and Relationships section denotes the API names of the custom fields in Salesforce.
Conclusion
In this Apex Tutorial, we learned how to get API Name of Fields, with the help of examples.