You can be as careful as you'd like, but sometimes the long arm of the law is at your door step anyway. First of all be polite and show respect. Don't make any aggressive moves. They may just see that you are OK and give you a warning. Remember someone complained and called them and they are just doing their job.
When you are talking to the police, talk to them outside your house or apartment and always make sure the door is closed behind you. This bears repeating. Always make sure the door is closed behind you. The best thing to do is to bring a sober friend (or a friend most sober) along with you to talk to the police in case you had too much too drink. That way you have a witness if something goes wrong. Ask them not to say too much. You should do most of the talking.
Police can only come in if they have a warrant or if there is an emergency. Otherwise they will ask you for permission to come in. The police are very good at this and they may politely ask to look around to make sure everyone is OK. You don't have to let them in. State politely and loudly (good tip in case witnesses are around) that everyone is okay and that you don't need their help and that they can't come in.
If you don't let them in, they will naturally want to ask you some questions. Please answer all their questions politely, just don't answer any questions that seem incriminating. They may ask if you are serving minors or if there are drugs at your party. A wrong answer to the question will give them motive to come in to your place since you have just admitted that a crime is being committed inside.
Similarly, you don't have to show them any identification. However, if are not underage you should do it anyway. They can find out regardless if they want to, so you have got nothing to lose, but it will show them your willingness to adhere to their authority.
Lastly if you are given a ticket or some sort of citation don't argue with the officers. It won't help you and could make things worse. Save your strength for your day in court.
A few more things to keep in mind when having a party.
Don't charge guests for drinks at your party. You need a liquor license for that. The best thing to do is to pitch in with a few friends and buy the alcohol together.
You must be between 18 and 21 years or older to consume alcohol in US and Canada depending on the state or province you are in. If you and/or your guests have not reached that age, you and/or your guests are therefore committing a crime when you drink or simply have alcohol in your possession. If you are of age but they are not, and you are serving them alcohol, that is also a crime. So save yourself the headaches. When you see people at the party who look too young or you simply don't know them, ask them for I.D. or ask them to leave.
Drinking and driving is another important factor for you as the host to keep in mind. If your guests leave your party and get in an accident and injure themselves and/or others, you could face law suits in addition to criminal charges. To prevent tragedy, please keep an eye out for people who are barely able to walk and are about to get into their cars and drive away. Offer to call them a taxi. If they don't have the money, offer to pay for their taxi or drive them home if you are OK to drive. You can also ask them to spend the night. Don't accept no for an answer. Do what ever it takes to make sure that no one drives home drunk.
Oh, and one last piece of advice. Have a great time, of course. Thats what parties were made for.